2190. Most Frequent Number Following Key In an Array
Содержание
class Solution:
def mostFrequent(self, nums: List[int], key: int) -> int:
cnt = Counter()
res = mx = 0
for a, b in pairwise(nums):
if a == key:
cnt[b] += 1
if mx < cnt[b]:
mx = cnt[b]
res = b
return res