3005. Count Elements With Maximum Frequency Easy

@problem@discussion
#Array#Hash Table#Counting



1/**
2 * [3005] Count Elements With Maximum Frequency
3 *
4 * You are given an array nums consisting of positive integers.
5 * Return the total frequencies of elements in nums such that those elements all have the maximum frequency.
6 * The frequency of an element is the number of occurrences of that element in the array.
7 *  
8 * <strong class="example">Example 1:
9 * 
10 * Input: nums = [1,2,2,3,1,4]
11 * Output: 4
12 * Explanation: The elements 1 and 2 have a frequency of 2 which is the maximum frequency in the array.
13 * So the number of elements in the array with maximum frequency is 4.
14 * 
15 * <strong class="example">Example 2:
16 * 
17 * Input: nums = [1,2,3,4,5]
18 * Output: 5
19 * Explanation: All elements of the array have a frequency of 1 which is the maximum.
20 * So the number of elements in the array with maximum frequency is 5.
21 * 
22 *  
23 * Constraints:
24 * 
25 * 	1 <= nums.length <= 100
26 * 	1 <= nums[i] <= 100
27 * 
28 */
29pub struct Solution {}
30
31// problem: https://leetcode.com/problems/count-elements-with-maximum-frequency/
32// discuss: https://leetcode.com/problems/count-elements-with-maximum-frequency/discuss/?currentPage=1&orderBy=most_votes&query=
33
34// submission codes start here
35
36impl Solution {
37    pub fn max_frequency_elements(nums: Vec<i32>) -> i32 {
38        0
39    }
40}
41
42// submission codes end
43
44#[cfg(test)]
45mod tests {
46    use super::*;
47
48    #[test]
49    fn test_3005() {
50    }
51}
52


Back
© 2025 bowen.ge All Rights Reserved.