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
jb7.0 extends.override
S
add
JAVA # Dizi Ortalama
post decrement
BinaryTreeFindNext_noParentPointer
Game developer
do whilee
rta
Apple Banana Pear question