Dashboard Temp Share Shortlinks Frames API

HTMLify

Day 115
Views: 2 | Author: djdj
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
class Solution {

    /**
     * @param Integer[] $nums
     * @return Integer
     */
    function maxFrequencyElements($nums) {
        $freq = array_count_values($nums); 
        $max_freq = max($freq);
        $count = 0;

        foreach ($freq as $num => $f) {
            if ($f == $max_freq) {
                $count += $f; 
            }
        }
        return $count;
    }
}