OA in AZ company
Anonymous User
267

I got a question which how many times you swap to get sorted array.
I thought was merge sort and waste time there. And bubble sort kind solved the issue but time limited exceeded.
[4,3,5,2,6] - > [2,3,4,5,6] how many swaps.

Too bad I waste so much time on the wrong approach. Anyone has optimized solution?

Found something alke
https://codereview.stackexchange.com/questions/206158/minimum-number-of-swaps-required-to-sort-the-array-in-ascending-order#:~:text=You%20are%20given%20an%20unordered,the%20array%20in%20ascending%20order.&text=It%20took%205%20swaps%20to%20sort%20the%20array.

Comments (2)