• + 0 comments

    Javascript:

    function equalizeArray(arr) {
        const counts = {};
        let max = 0;
        for (let i = 0; i < arr.length; i++) {
            counts[arr[i]] = (counts[arr[i]] || 0) + 1;
            max = Math.max(counts[arr[i]], max);
        }
        return arr.length - max;
    }