The main task of this problem is to perform swaps. The simplest way to swap two numbers A and B is as follows:
Take a temporary variable C.
Assign A to C.
Copy B to A.
Copy C to B.
Swapping can also be performed without the temporary C. Why?
Setter’s Complexity: O(S)