def solution(X, A): positions = set() for i in range(len(A)): if A[i] not in positions: positions.add(A[i]) if len(positions) == X: return i return -1
时间: 2024-11-08 20:32:14
def solution(X, A): positions = set() for i in range(len(A)): if A[i] not in positions: positions.add(A[i]) if len(positions) == X: return i return -1