• + 0 comments

    PHP

    function equalizeArray($arr) {
        $counter = [];
        $max = [];
        foreach ($arr as $el) {
            isset($counter[$el]) ? $counter[$el]++ : $counter[$el] = 1;
            if ($counter[$el] > $max['value']) {
                $max['value'] = $counter[$el];
                $max['index'] = $el;
            }
        }
        
        unset($counter[$max['index']]);
        return array_sum($counter);
    }