You are viewing a single comment's thread. Return to all comments →
i didnot understand ur code but it was some what similar to mycode..... can u please tell what's wrong in my code.....
and what is enumerate....???
def minimumSwaps(arr):
count=0
for i in range(len(arr)):
if(arr[i]!=i+1):
temp=arr[i]
arr[i]=arr[arr.index(i+1)]
arr[arr.index(i+1)]=temp
count+=1
return count
Minimum Swaps 2
You are viewing a single comment's thread. Return to all comments →
i didnot understand ur code but it was some what similar to mycode..... can u please tell what's wrong in my code.....
and what is enumerate....???
def minimumSwaps(arr):
for i in range(len(arr)):
if(arr[i]!=i+1):
temp=arr[i]
arr[i]=arr[arr.index(i+1)]
arr[arr.index(i+1)]=temp
count+=1
return count