You are viewing a single comment's thread. Return to all comments →
sorry i can't explain it in comment box
it's little bit tricky
array is full with consecutive int value
so it is sure that in index 0 the value will be 1 as the array is consisting of consecutive integers [1, 2, 3, ..., n] without any duplicates
so in arr[arr[first]-1] they are shifting the value to it's correct place
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 →
sorry i can't explain it in comment box
it's little bit tricky
array is full with consecutive int value
so it is sure that in index 0 the value will be 1 as the array is consisting of consecutive integers [1, 2, 3, ..., n] without any duplicates
so in arr[arr[first]-1] they are shifting the value to it's correct place