-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Description
Bug Report for https://neetcode.io/problems/find-duplicate-integer
In the provided solution based on bit manipulation, there is a wrong assumption:
Every number from 1 to n−1 should appear exactly once, but in the array, one number appears twice
Some of the numbers from 1 to n-1 appear exactly once, except one number that appears more than once (it could appear more than two times). If that number appears only twice, then every number from 1 to n-1 appear exactly once except that one. However, if that number appears more than twice, there must be at least one missing number from 1 to n−1.
The provided solution is correct under that assumption, but the assumption itself is wrong for this question, and it causes the provided solution to be incorrect.