HackerRank: Equalize the Array (Easy)

Link to code challenge
function equalizeArray(arr) { let count = {}; let greatest = 1; for (let num of arr) { if (count.hasOwnProperty(num)) { count[num]++; if (count[num] > greatest) greatest = count[num]; } else count[num] = 1; } return arr.length - greatest; }

Comments

Popular posts from this blog

Code Wars: Data Reverse (6 kyu)

Code Wars: longest_palindrome (6 kyu)

Code Wars: Find the odd int