Codeforces
CF Step
Youtube Linkedin Discord Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

Hints

An array can be sorted if it’s possible to swap ANY 2 elements while keeping the order of other elements intact.
Swapping of 2 elements is a big requirement. Think small, if you are only allowed to swap any 2 adjacent elements, can you still sort the array?
In fact, using just adjacent swaps, it is possible to swap 2 arbitrary elements. How?
If k >= 2, then adjacent swaps are allowed, hence, arbitrary swaps are also allowed. Hence, sorting is always possible. In fact, Insertion Sort relies on the idea of adjacent swaps.