4 ms·
Unless I'm misreading, the question as stated in the blog post never says there is only one duplicate (there might be many!), so in that sense I think his answe
by williamkuszmaul 4y ago
Unless I'm misreading, the question as stated in the blog post never says there is only one duplicate (there might be many!), so in that sense I think his answer may be wrong. A more robust solution is just to have an array of n counters and just count how many times each item appears.
- philiiiiiipp 4y ago> when given an array of length n + 1 containing integers 1 through n, find the duplicate integer in an array. I do believe it is only one.
- jhot 4y agoThe length is n+1 and contains all ints 1 through n, so there can only be a single duplicate.
- williamkuszmaul 4y agoBut does the question ever say "all"...?