2404. Most Frequent Even Element
Содержание
class Solution:
def mostFrequentEven(self, nums: List[int]) -> int:
cnt = Counter(x for x in nums if x % 2 == 0)
res, mx = -1, 0
for x, v in cnt.items():
if v > mx or (v == mx and res > x):
res, mx = x, v
return res