2260. Minimum Consecutive Cards to Pick Up
Содержание
class Solution:
def minimumCardPickup(self, cards: List[int]) -> int:
last = {}
res = inf
for i, x in enumerate(cards):
if x in last:
res = min(res, i - last[x] + 1)
last[x] = i
return -1 if res == inf else res