Quant Memo
Coding/●●●●

Find the duplicate number without modifying the array

Asked at Jane Street

You are handed an array nums of length n+1n+1 where every value is between 11 and nn inclusive. By the pigeonhole principle at least one value repeats, and in this problem exactly one value repeats (possibly many times).

Find the duplicate using O(1)O(1) extra space, without modifying the array. Sorting or a hash set are the easy answers, the interviewer wants neither.

Your answer

This one is open-ended. Work it through, then check your reasoning against the full solution.

More Coding questions