You are viewing a single comment's thread. Return to all comments →
Thank you, but you need to add a condition to avoid ArrayOutOfBoundException by replacing the line
if(i+1!=a[i])
with
if(i+1!=a[i] && i less than a.length-1)
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 →
Thank you, but you need to add a condition to avoid ArrayOutOfBoundException by replacing the line
with
if(i+1!=a[i] && i less than a.length-1)