Back to course home
0% completed
Vote For New Content
Variables in solution - poorly named and lacking explanation
davemednikov
Nov 16, 2023
This solution has several variables that could use better naming and explanation in the solution.
The purpose of i can be understood to be the current index when iterating through the list of numbers.
However what about the variable j? What does the assignment in j = nums[i] - 1 represent? Is this supposed to be the expected index for the current number?
What are we checking for in if nums[i] != nums[j]:? That the number at the current index is not equal to the number we expect to see at the current index? What are we achieving with this swap?
Other explanations have been much more in depth but this one was a bit lacking. Please advise. Thank you!
0
0
Comments
Comments
On this page