Back to course home
0% completed
Vote For New Content
When I try [3, 1, 3, 4, 2] as the input, the nums list looks like [1, 2, 3, 4, ...
Gary
Mar 31, 2022
When I try [3, 1, 3, 4, 2] as the input, the nums list looks like [1, 2, 3, 4, 3] after running through the while loop in the solution, which does not appear to be sorted correctly even though the results are correct?
0
0
Comments
Comments
Design Gurus4 years ago
Yes, this is correct. The goal here is to place each number in its correct place. This will result in a sorted array if there are no duplicates (cyclic sort ensures that). But if there are duplicates, all duplicated numbers will be scattered in the array and will be on ...