Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Value pair analysis
//'main' method must be in a class 'Rextester'. //Compiler version 1.8.0_111 //Value pair analysis import java.util.*; import java.lang.*; import java.io.*; class Rextester{ public static void main(String args[]){ Scanner rd = new Scanner(System.in); int utr = rd.nextInt(); int[] arr = new int[utr]; for (int i = 0; i < utr; i++){ arr[i] = -rd.nextInt()+rd.nextInt(); } int max = 0; int rep; int lst = 0; for (int i = 0; i < utr; i++){ rep = 0; for (int s = 0; s < utr; s++){ if (arr[i] == arr[s]){ rep ++; } } if (rep > lst){ max = arr[i]; lst = rep; }else if (rep == lst){ max = Math.max(arr[i], max); } } System.out.println(max); } } /* Input: 7 10 58 15 315 20 408 100 1000 32 63 32 63 11 121 Output: 31 */
run
|
edit
|
history
|
help
0
Fibonacci numbers 0 - 94
Engine Java
1a
Convert ArrayList to array in java
// Java Coding Challenge - 07: Print out Fibonacci number 0 - 1000
toStringMethodinJava
4pr
1 e
jkbvlghckgh
sq-buzz