Grokking the Coding Interview: Patterns for Coding Questions
Ask Author
Back to course home

0% completed

Vote For New Content
Why does this solution not contain the line if nums[i] != i + 1: # Check if the current element is in its correct position

Joe

Mar 5, 2024

It would seem both Find the Duplicate Number and Find all Duplicate Numbers should be the same solution only this time capturing a list for all dupes. However the duplicate number has the line:

  `if nums[i] != i + 1:  # Check if the current element is in its correct position`

Why does this solution work without this and the previous problem does not if they are essentially the same problem?

1

0

Comments
Comments

On this page