Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const jury = +gets();
- const votes = Array.from({
- length: jury
- }).map(() => +gets()).sort((a, b) => (a - b));
- let currentSum = 1;
- let maxSum = 0;
- let mostCommon;
- for (let i = 0; i < votes.length; i++) {
- if (votes[i] === votes[i + 1]) {
- currentSum += 1;
- } else {
- currentSum = 1;
- }
- if (maxSum < currentSum) {
- maxSum = currentSum;
- mostCommon = votes[i];
- }
- }
- if (!(maxSum)) {
- print(Math.min(...votes));
- } else {
- print(mostCommon);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement