Given a permutation of first n natural numbers as an array and an integer k. Print the lexicographically largest permutation after at most k swaps.
The first line of input contains an integer T denoting the number of test cases. Each test case contains two integers n and k where n denotes the number of elements in the array a. Next line contains space separated n elements in the array a.
Print space separated n integers which form the largest permutation after at most k swaps.
4 5 2 1 3
2 1 3
5 4 3 2 1
3 1 2
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.