News for hackers. Stuff that matters.
Re:I cheated on my Microsoft interview (2019) by williamkuszmaul on Sunday June 05, 2022 @05:40AM (#31629406)
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.
Re:I cheated on my Microsoft interview (2019) by philiiiiiipp on Sunday June 05, 2022 @05:50AM (#31629460)
> 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.

Re:I cheated on my Microsoft interview (2019) by jhot on Sunday June 05, 2022 @05:53AM (#31629480)
The length is n+1 and contains all ints 1 through n, so there can only be a single duplicate.
Re:I cheated on my Microsoft interview (2019) by williamkuszmaul on Sunday June 05, 2022 @11:49AM (#31632049)
But does the question ever say "all"...?