Advertisement
Guest User

Untitled

a guest
May 25th, 2022
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const test = [
  2.     '5',
  3.     '1',
  4.     '6',
  5.     '6',
  6.     '8',
  7.     '8',
  8. ];
  9.  
  10. let n = Number(gets());
  11. let numbers = [];
  12. let repeatingNum = 0;
  13. let repeatingCount = 0;
  14.  
  15. for (let i = 0; i < n; i++) {
  16.     let num = gets();
  17.     numbers.push(Number(num));
  18. }
  19.  
  20. numbers.sort((a, b) => a - b);
  21. for (let i = 0; i <= numbers.length; i++) {
  22.     let currNum = numbers[i];
  23.     let count = 1;
  24.     for (let j = i + 1; j < numbers.length; j++) {
  25.         if (currNum == numbers[j]) count++;
  26.     }
  27.  
  28.     if (count > repeatingCount) {
  29.         repeatingCount = count;
  30.         repeatingNum = currNum;
  31.     }
  32. }
  33.  
  34. print(repeatingNum, repeatingCount);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement