Duplicates close together

A code exercise of about 15 minutes: read the statement, solve «Duplicates close together» in the browser and get a review like in a real interview.

Code · 15 min
Loading…

Statement

Write containsNearbyDuplicate(nums, k): return true if there are two different positions i and j holding the same number and at most k apart (|i − j| ≤ k). k can be 0. The list can hold 100,000 numbers and k can be big.