python-algorithm
leetcode 3005. Count Elements With Maximum Frequency
무적김두칠
2024. 1. 15. 17:04
https://leetcode.com/problems/count-elements-with-maximum-frequency/description/
Count Elements With Maximum Frequency - LeetCode
Can you solve this real interview question? Count Elements With Maximum Frequency - You are given an array nums consisting of positive integers. Return the total frequencies of elements in nums such that those elements all have the maximum frequency. The
leetcode.com
1 2 3 4 5 6 | class Solution: def maxFrequencyElements(self, nums: List[int]) -> int: fre_nums = [nums.count(x) for x in nums] max_fre = max(fre_nums) return fre_nums.count(max_fre) | cs |
반응형