| 模型 | 模型答案 | 正确答案 |
|---|---|---|
| 金声玉亮2.0 | ```python from collections import Counter # Count the frequency of each element in nums frequency = Counter(nums) # Find the maximum frequency max_freq = max(frequency.values()) # Calculate the total number of elements with the maximum frequency total_elements = sum(count for count in frequency.values() if count == max_freq) return total_elements ``` |
class Solution(object): def maxFrequencyElements(self, nums): """ :type nums: List[int] :rtype: int """ cnt = collections.Counter(nums) mx = max(cnt.values()) return sum(v for v in cnt.values() if v == mx) |
| deepseek-r1 | ``` from collections import Counter freq = Counter(nums) max_frequency = max(freq.values()) count = sum(1 for v in freq.values() if v == max_frequency) return max_frequency * count ``` |
class Solution(object): def maxFrequencyElements(self, nums): """ :type nums: List[int] :rtype: int """ cnt = collections.Counter(nums) mx = max(cnt.values()) return sum(v for v in cnt.values() if v == mx) |
| gpto1 | ```python """ """ from collections import Counter c = Counter(nums) max_freq = max(c.values()) total = sum(freq for freq in c.values() if freq == max_freq) return total ``` |
class Solution(object): def maxFrequencyElements(self, nums): """ :type nums: List[int] :rtype: int """ cnt = collections.Counter(nums) mx = max(cnt.values()) return sum(v for v in cnt.values() if v == mx) |
| gpt-4o-2024-08-06 | ```python :rtype: int """ from collections import Counter # Count the frequency of each element in nums frequency = Counter(nums) # Find the maximum frequency max_freq = max(frequency.values()) # Calculate the total frequencies of elements with the maximum frequency total_max_freq_elements = sum(freq for freq in frequency.values() if freq == max_freq) return total_max_freq_elements ``` |
class Solution(object): def maxFrequencyElements(self, nums): """ :type nums: List[int] :rtype: int """ cnt = collections.Counter(nums) mx = max(cnt.values()) return sum(v for v in cnt.values() if v == mx) |
| DeepSeek-Coder-V2-Lite-Instruct | ```python class Solution(object): def maxFrequencyElements(self, nums): """ :type nums: List[int] :rtype: int """ frequency = {} for num in nums: frequency[num] = frequency.get(num, 0) + 1 max_freq = max(frequency.values()) count = 0 for freq in frequency.values(): if freq == max_freq: count += 1 return count ``` |
class Solution(object): def maxFrequencyElements(self, nums): """ :type nums: List[int] :rtype: int """ cnt = collections.Counter(nums) mx = max(cnt.values()) return sum(v for v in cnt.values() if v == mx) |
| Meta-Llama-3.1-405B-Instruct-Turbo | ```python freq = {} for num in nums: if num in freq: freq[num] += 1 else: freq[num] = 1 max_freq = max(freq.values()) return sum(value for value in freq.values() if value == max_freq) * max_freq ``` |
class Solution(object): def maxFrequencyElements(self, nums): """ :type nums: List[int] :rtype: int """ cnt = collections.Counter(nums) mx = max(cnt.values()) return sum(v for v in cnt.values() if v == mx) |
| Meta-Llama-3.1-70B-Instruct-Turbo | ```python freq = {} for num in nums: if num in freq: freq[num] += 1 else: freq[num] = 1 max_freq = max(freq.values()) count = 0 for key, value in freq.items(): if value == max_freq: count += value return count ``` |
class Solution(object): def maxFrequencyElements(self, nums): """ :type nums: List[int] :rtype: int """ cnt = collections.Counter(nums) mx = max(cnt.values()) return sum(v for v in cnt.values() if v == mx) |
| Qwen2-72B-Instruct | ```python :rtype: int """ from collections import Counter count = Counter(nums) max_freq = max(count.values()) return sum(value for value, freq in count.items() if freq == max_freq) ``` |
class Solution(object): def maxFrequencyElements(self, nums): """ :type nums: List[int] :rtype: int """ cnt = collections.Counter(nums) mx = max(cnt.values()) return sum(v for v in cnt.values() if v == mx) |
| baichuan4 | ```python from collections import Counter # Count the frequency of each element in the array freq_map = Counter(nums) # Find the maximum frequency max_freq = max(freq_map.values()) # Count the number of elements with the maximum frequency count = sum(1 for freq in freq_map.values() if freq == max_freq) return count ``` |
class Solution(object): def maxFrequencyElements(self, nums): """ :type nums: List[int] :rtype: int """ cnt = collections.Counter(nums) mx = max(cnt.values()) return sum(v for v in cnt.values() if v == mx) |
| doubao | ```python class Solution(object): def maxFrequencyElements(self, nums): """ :type nums: List[int] """ from collections import Counter count = Counter(nums) max_count = max(count.values()) return sum(1 for val, freq in count.items() if freq == max_count) ``` |
class Solution(object): def maxFrequencyElements(self, nums): """ :type nums: List[int] :rtype: int """ cnt = collections.Counter(nums) mx = max(cnt.values()) return sum(v for v in cnt.values() if v == mx) |
| gpto1 | ```python """ """ from collections import Counter c = Counter(nums) max_freq = max(c.values()) total = sum(freq for freq in c.values() if freq == max_freq) return total ``` |
class Solution(object): def maxFrequencyElements(self, nums): """ :type nums: List[int] :rtype: int """ cnt = collections.Counter(nums) mx = max(cnt.values()) return sum(v for v in cnt.values() if v == mx) |
| kimi | ```python from collections import Counter class Solution(object): def maxFrequencyElements(self, nums): """ :type nums: List[int] :rtype: int """ count = Counter(nums) max_count = max(count.values()) result = 0 for key, value in count.items(): if value == max_count: result += 1 return result * max_count ``` |
class Solution(object): def maxFrequencyElements(self, nums): """ :type nums: List[int] :rtype: int """ cnt = collections.Counter(nums) mx = max(cnt.values()) return sum(v for v in cnt.values() if v == mx) |
| minimax | ```python from collections import Counter class Solution(object): def maxFrequencyElements(self, nums): """ :type nums: List[int] :rtype: int """ freq = Counter(nums) max_freq = max(freq.values()) return sum(1 for value in freq.values() if value == max_freq) ``` |
class Solution(object): def maxFrequencyElements(self, nums): """ :type nums: List[int] :rtype: int """ cnt = collections.Counter(nums) mx = max(cnt.values()) return sum(v for v in cnt.values() if v == mx) |
| wenxinyiyan | ```python from collections import Counter # Count the frequency of each element freq_counter = Counter(nums) # Find the maximum frequency max_freq = max(freq_counter.values()) # Count the number of elements with maximum frequency count = sum(1 for freq in freq_counter.values() if freq == max_freq) # Since we want the total number of elements (not distinct elements), # we multiply the count by the maximum frequency total_elements = count * max_freq # However, if all elements have the same frequency (i.e., max_freq is 1), # we should return the length of the array instead if max_freq == 1: return len(nums) return total_elements ``` **Note**: The provided solution has a logical error in the last step. We should not multiply `count` by `max_freq` to get `total_elements` because `count` already represents the number of distinct elements with the maximum frequency. Instead, we need to sum up the occurrences of all elements with the maximum frequency. Here's the corrected version: ```python from collections import Counter # Count the frequency of each element freq_counter = Counter(nums) # Find the maximum frequency max_freq = max(freq_counter.values()) # Count the total number of elements with maximum frequency total_elements = sum(freq for freq in freq_counter.values() if freq == max_freq) return total_elements ``` In this corrected version, we use a generator expression to sum up the frequencies of all elements that have the maximum frequency. This gives us the total number of elements (not distinct elements) with the maximum frequency, as required by the problem. |
class Solution(object): def maxFrequencyElements(self, nums): """ :type nums: List[int] :rtype: int """ cnt = collections.Counter(nums) mx = max(cnt.values()) return sum(v for v in cnt.values() if v == mx) |
| zhipu | ```python from collections import Counter freqs = Counter(nums) max_freq = max(freqs.values()) return sum(freq == max_freq for freq in freqs.values()) ``` |
class Solution(object): def maxFrequencyElements(self, nums): """ :type nums: List[int] :rtype: int """ cnt = collections.Counter(nums) mx = max(cnt.values()) return sum(v for v in cnt.values() if v == mx) |
| deepseek-v3 | ```python :rtype: int """ from collections import Counter cnt = Counter(nums) max_freq = max(cnt.values()) total = sum(v for v in cnt.values() if v == max_freq) return total ``` |
class Solution(object): def maxFrequencyElements(self, nums): """ :type nums: List[int] :rtype: int """ cnt = collections.Counter(nums) mx = max(cnt.values()) return sum(v for v in cnt.values() if v == mx) |