Plz tell error in this (unlock)
Hi,
Solve this problem by taking into consideration that at most k swaps are required. Not exactly k swaps.
Can u plz tell the test case it might be failing
how will it matter if i use k swaps ans would be same ??
@Namanjain123
You should iterate left to right instead of right to left as the swaps would matter. Also, you have not done the actual swapping in the array itself.
Try this testcase -
Input :
10 5
2 8 4 1 6 7 5 3 9 10
Expected Output :
10 9 8 7 6 5 1 3 4 2
Correct Output :
10 9 8 6 5 1 7 3 4 2
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.