You are viewing a single comment's thread. Return to all comments →
Here are few test cases to further help understand the problem: (as the provided test cases do not cover K > 1)
Input: 5 2 4 3 2 5 1 Intermediate: After first swap (of 5 and 4): 5 3 2 4 1 After second swap (of 3 and 4): 5 4 2 3 1 Output: 5 4 2 3 1
Input: 5 2 3 4 2 5 1 Intermediate: After first swap (of 5 and 3): 5 4 2 3 1 After second swap (of 2 and 3): 5 4 3 2 1 Output: 5 4 3 2 1
Seems like cookies are disabled on this browser, please enable them to open this website
Largest Permutation
You are viewing a single comment's thread. Return to all comments →
Here are few test cases to further help understand the problem: (as the provided test cases do not cover K > 1)