ids in the order people pass through. It looks suspicious when the same badge is scanned twice too close together.
Return True if there are two different positions i and j with ids[i] == ids[j] and |i - j| ≤ reach. Otherwise return False.ids=[7, 3, 9, 7], reach=3 → True
Badge 7 was scanned at positions 0 and 3: 3 apart, which is within reach.
ids=[7, 3, 9, 7], reach=2 → False
Same two scans, but now only a distance of 2 is allowed.
ids=[4, 4], reach=0 → False
ids=[7, 3, 9, 7], reach=3
True
Run checks the first 3 tests in your browser. Submit checks all 104 tests on the server, hidden ones included.