2260. Minimum Consecutive Cards to Pick Up
class Solution:
def minimumCardPickup(self, cards: List[int]) -> int:
card_dict, answer = dict(), float('inf')
for i, v in enumerate(cards):
if v in card_dict:
answer = min(i-card_dict[v] + 1, answer)
card_dict[v] = i
return -1 if answer == float('inf') else answer