You are viewing a single comment's thread. Return to all comments →
I also though on that logic, but there is a test case where the numbers are not 1 to n
1 3 5 2 4 8 6
So in there is missing the 7, so when you try to move 8 from its position 5 to its position 7 crash, because the array do not have position 7.
Am I doing someting wrong on the logic?
Seems like cookies are disabled on this browser, please enable them to open this website
Minimum Swaps 2
You are viewing a single comment's thread. Return to all comments →
I also though on that logic, but there is a test case where the numbers are not 1 to n
1 3 5 2 4 8 6
So in there is missing the 7, so when you try to move 8 from its position 5 to its position 7 crash, because the array do not have position 7.
Am I doing someting wrong on the logic?