Unlock qns not able to find which case is not working it gives only 75

Test case 1 is giving wrong answer/TLE.
Please consider it as ATMOST K SWAPS instead of EXACTLY K SWAPS

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.

i do until it not submitted fully

@sgdon142
Hello sparsh,
your logic is totally correct .
reason for time limit is below shown snippet
image

due to this portion of ur code ur are getting tle (beacuse this section has time complexity o(N^2) )

to improve time complexity use map.

image

https://ide.codingblocks.com/s/188772

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.