Skip to content

Conversation

@vidyasreekumar
Copy link

Finding missing number in a sorted consecutive array using binary search

@super30admin
Copy link
Owner

  • The solution is well-implemented and correctly solves the problem. The binary search logic is correctly applied to find the missing number.
  • The code is clean and follows good practices, such as using low + (high - low) / 2 to avoid potential integer overflow.
  • The comments are helpful but could be slightly more detailed to explain why the solution works (e.g., mentioning that the array is expected to start at 1 and be consecutive except for one missing number).
  • The return statement return arr[low]-1; is correct but might benefit from a comment explaining why this works (i.e., because low ends up at the index where the missing number should be, and arr[low] is one more than the missing number).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants