Contains duplicate within distance K

0
Remix

Return whether an array has two equal values whose indices differ by at most k. Start with a map from value to its last index. Follow-up: cut the extra space to O(k) by dropping indices that fall out of the window as you go.

MetaTechnical phone screenLast asked Aug 2025
No answer yet. Write the first one; the best answer gets endorsed.