SAP | Online Assessment | Minimum Swaps
Anonymous User
1835

Given an array return an integer indicating the minimum number of swap operations required to sort the array into ascending order.

Examples:-
1.)
arr=[5,1,3,2]
final_arr=[1,2,3,5]
minimum no. of swaps = 2

2.)
arr=[1,3,2]
final_arr=[1,2,3]
minimum no. of swaps = 1

Comments (2)