Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const test = [
- '5',
- '1',
- '6',
- '6',
- '8',
- '8',
- ];
- let n = Number(gets());
- let numbers = [];
- let repeatingNum = 0;
- let repeatingCount = 0;
- for (let i = 0; i < n; i++) {
- let num = gets();
- numbers.push(Number(num));
- }
- numbers.sort((a, b) => a - b);
- for (let i = 0; i <= numbers.length; i++) {
- let currNum = numbers[i];
- let count = 1;
- for (let j = i + 1; j < numbers.length; j++) {
- if (currNum == numbers[j]) count++;
- }
- if (count > repeatingCount) {
- repeatingCount = count;
- repeatingNum = currNum;
- }
- }
- print(repeatingNum, repeatingCount);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement