You are viewing a single comment's thread. Return to all comments →
This is my solution in Go
func minimumSwaps(arr []int32) int32 { swaps := int32(0) i := 0 for i < len(arr) { if arr[i] != int32(i+1) { arr[arr[i]-1], arr[i] = arr[i], arr[arr[i]-1] swaps++ } else { i++ } } return swaps }
Minimum Swaps 2
You are viewing a single comment's thread. Return to all comments →
This is my solution in Go