Advertisement
CR7CR7

maxoccurance

May 25th, 2022
1,146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let num = +gets();
  2. let array = [];
  3. let repeatPlace = [];
  4.  
  5. for (i = 0; i <= 10; i++) {
  6.   repeatPlace.push(0);
  7. }
  8.  
  9. let maxRepNum = 0;
  10. let maxRepPlace = 0;
  11.  
  12. for (i = 0; i < num; i++) {
  13.   currentNum = +gets();
  14.   repeatPlace[currentNum]++;
  15.   currentPlace = repeatPlace[currentNum];
  16.   if (currentPlace > maxRepPlace) {
  17.     maxRepNum = currentNum;
  18.     maxRepPlace = currentPlace;
  19.   }
  20. }
  21. print(maxRepNum);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement