• + 0 comments

    JavaScript

    function equalizeArray(arr) {
        // Write your code here
        let obj = {};
        arr.forEach(value => {
            obj[value] = obj[value] ? obj[value] + 1 : 1
        });
        
        arr = Array.from(Object.values(obj));
        
        let result = arr.reduce((sum, value) => sum += value) - Math.max(...arr);
        
        return result
    
    }