| 模型 | 模型答案 | 正确答案 |
|---|---|---|
| 金声玉亮2.0 | ```python from typing import List from collections import Counter class Solution: def maxFrequencyElements(self, nums: List[int]) -> int: frequency = Counter(nums) max_freq = max(frequency.values()) return sum(count for count in frequency.values() if count == max_freq) ``` |
[{"input": "[1, 2, 2, 3, 1, 4]", "output": "4", "testtype": "functional"}, {"input": "[1, 2, 3, 4, 5]", "output": "5", "testtype": "functional"}] |
| deepseek-r1 | ```python from typing import List from collections import Counter class Solution: def maxFrequencyElements(self, nums: List[int]) -> int: counts = Counter(nums) max_freq = max(counts.values(), default=0) return sum(freq for freq in counts.values() if freq == max_freq) ``` |
[{"input": "[1, 2, 2, 3, 1, 4]", "output": "4", "testtype": "functional"}, {"input": "[1, 2, 3, 4, 5]", "output": "5", "testtype": "functional"}] |
| gpto1 | ```python class Solution: def maxFrequencyElements(self, nums: List[int]) -> int: from collections import Counter count = Counter(nums) max_freq = max(count.values()) total = sum(freq for freq in count.values() if freq == max_freq) return total ``` |
[{"input": "[1, 2, 2, 3, 1, 4]", "output": "4", "testtype": "functional"}, {"input": "[1, 2, 3, 4, 5]", "output": "5", "testtype": "functional"}] |
| gpt-4o-2024-08-06 | ```python from typing import List from collections import Counter class Solution: def maxFrequencyElements(self, nums: List[int]) -> int: # Count the frequency of each element in nums frequency = Counter(nums) # Find the maximum frequency max_freq = max(frequency.values()) # Sum the frequencies of elements that have the maximum frequency total_max_freq_elements = sum(freq for freq in frequency.values() if freq == max_freq) return total_max_freq_elements ``` |
[{"input": "[1, 2, 2, 3, 1, 4]", "output": "4", "testtype": "functional"}, {"input": "[1, 2, 3, 4, 5]", "output": "5", "testtype": "functional"}] |
| DeepSeek-Coder-V2-Lite-Instruct | ```python from typing import List from collections import Counter class Solution: def maxFrequencyElements(self, nums: List[int]) -> int: frequency_count = Counter(nums) max_frequency = max(frequency_count.values()) return sum(1 for freq in frequency_count.values() if freq == max_frequency) ``` |
[{"input": "[1, 2, 2, 3, 1, 4]", "output": "4", "testtype": "functional"}, {"input": "[1, 2, 3, 4, 5]", "output": "5", "testtype": "functional"}] |
| Meta-Llama-3.1-405B-Instruct-Turbo | ```python from typing import List from collections import Counter class Solution: def maxFrequencyElements(self, nums: List[int]) -> int: # Count the frequency of each element in the array freq = Counter(nums) # Find the maximum frequency max_freq = max(freq.values()) # Count the number of elements with the maximum frequency count = sum(value == max_freq for value in freq.values()) * max_freq return count ``` |
[{"input": "[1, 2, 2, 3, 1, 4]", "output": "4", "testtype": "functional"}, {"input": "[1, 2, 3, 4, 5]", "output": "5", "testtype": "functional"}] |
| Meta-Llama-3.1-70B-Instruct-Turbo | ```python from typing import List from collections import Counter class Solution: def maxFrequencyElements(self, nums: List[int]) -> int: count = Counter(nums) max_freq = max(count.values()) return sum(val for val in count.values() if val == max_freq) * max_freq ``` |
[{"input": "[1, 2, 2, 3, 1, 4]", "output": "4", "testtype": "functional"}, {"input": "[1, 2, 3, 4, 5]", "output": "5", "testtype": "functional"}] |
| Qwen2-72B-Instruct | ```python class Solution: def maxFrequencyElements(self, nums: List[int]) -> int: from collections import Counter c = Counter(nums) max_freq = max(c.values()) return sum([freq for freq in c.values() if freq == max_freq]) ``` |
[{"input": "[1, 2, 2, 3, 1, 4]", "output": "4", "testtype": "functional"}, {"input": "[1, 2, 3, 4, 5]", "output": "5", "testtype": "functional"}] |
| baichuan4 | ```python from typing import List class Solution: def maxFrequencyElements(self, nums: List[int]) -> int: # Count the frequency of each element frequency = {} for num in nums: frequency[num] = frequency.get(num, 0) + 1 # Find the maximum frequency max_freq = max(frequency.values()) # Count the number of elements with the maximum frequency return sum(freq == max_freq for freq in frequency.values()) ``` |
[{"input": "[1, 2, 2, 3, 1, 4]", "output": "4", "testtype": "functional"}, {"input": "[1, 2, 3, 4, 5]", "output": "5", "testtype": "functional"}] |
| doubao | ```python class Solution: def maxFrequencyElements(self, nums: List[int]) -> int: from collections import Counter count = Counter(nums) max_freq = max(count.values()) return sum(1 for val, freq in count.items() if freq == max_freq) ``` |
[{"input": "[1, 2, 2, 3, 1, 4]", "output": "4", "testtype": "functional"}, {"input": "[1, 2, 3, 4, 5]", "output": "5", "testtype": "functional"}] |
| gpto1 | ```python class Solution: def maxFrequencyElements(self, nums: List[int]) -> int: from collections import Counter count = Counter(nums) max_freq = max(count.values()) total = sum(freq for freq in count.values() if freq == max_freq) return total ``` |
[{"input": "[1, 2, 2, 3, 1, 4]", "output": "4", "testtype": "functional"}, {"input": "[1, 2, 3, 4, 5]", "output": "5", "testtype": "functional"}] |
| kimi | ```python from typing import List from collections import Counter class Solution: def maxFrequencyElements(self, nums: List[int]) -> int: count = Counter(nums) max_count = max(count.values()) total = 0 for num, freq in count.items(): if freq == max_count: total += 1 return total ``` |
[{"input": "[1, 2, 2, 3, 1, 4]", "output": "4", "testtype": "functional"}, {"input": "[1, 2, 3, 4, 5]", "output": "5", "testtype": "functional"}] |
| minimax | ```python from collections import Counter class Solution: def maxFrequencyElements(self, nums: List[int]) -> int: # Count the frequency of each element in nums freq = Counter(nums) # Find the maximum frequency max_freq = max(freq.values()) # Count how many elements have the maximum frequency return sum(1 for count in freq.values() if count == max_freq) ``` |
[{"input": "[1, 2, 2, 3, 1, 4]", "output": "4", "testtype": "functional"}, {"input": "[1, 2, 3, 4, 5]", "output": "5", "testtype": "functional"}] |
| wenxinyiyan | ```python from collections import Counter from typing import List class Solution: def maxFrequencyElements(self, nums: List[int]) -> int: # Calculate the frequency of each element in nums 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) # Alternatively, you can use the following line instead of the above two lines: # count = freq_counter.most_common(1)[0][1] * len([f for f in freq_counter.values() if f == freq_counter.most_common(1)[0][1]]) # But it's less efficient because it calls most_common() twice. # Return the count of elements with maximum frequency return count * max_freq # Note: The original problem statement asks for the total frequencies of elements with maximum frequency, # which is equivalent to the count of those elements multiplied by their maximum frequency. # If the problem only requires the count of elements with maximum frequency, # you can simply return `count` instead of `count * max_freq`. # Corrected version based on the clarification in the comments: class CorrectedSolution: def maxFrequencyElements(self, nums: List[int]) -> int: # Calculate the frequency of each element in nums 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) # Return the count of elements with maximum frequency (not the total frequency) return count # Since the clarification indicates that we should return the count of elements, # the CorrectedSolution class provides the accurate implementation. ``` **Note**: After clarification from the comments, it seems that the original problem statement might have been interpreted differently. If the intention is to return the count of elements with the maximum frequency (and not the sum of their frequencies), then the `CorrectedSolution` class provides the correct implementation. I've included both versions for clarity. |
[{"input": "[1, 2, 2, 3, 1, 4]", "output": "4", "testtype": "functional"}, {"input": "[1, 2, 3, 4, 5]", "output": "5", "testtype": "functional"}] |
| zhipu | ```python from typing import List class Solution: def maxFrequencyElements(self, nums: List[int]) -> int: frequency = {} max_freq = 0 total_max_freq_elements = 0 for num in nums: frequency[num] = frequency.get(num, 0) + 1 max_freq = max(max_freq, frequency[num]) for count in frequency.values(): if count == max_freq: total_max_freq_elements += count return total_max_freq_elements ``` |
[{"input": "[1, 2, 2, 3, 1, 4]", "output": "4", "testtype": "functional"}, {"input": "[1, 2, 3, 4, 5]", "output": "5", "testtype": "functional"}] |
| deepseek-v3 | ```python from collections import Counter class Solution: def maxFrequencyElements(self, nums: List[int]) -> int: count = Counter(nums) max_freq = max(count.values()) return sum(freq for freq in count.values() if freq == max_freq) ``` |
[{"input": "[1, 2, 2, 3, 1, 4]", "output": "4", "testtype": "functional"}, {"input": "[1, 2, 3, 4, 5]", "output": "5", "testtype": "functional"}] |