performing the required swap operations
num [ i ] , num [ rightMax [ i ] ] = num [ rightMax [ i ] ] , num [ i ] NEW_LINE num [ n - i - 1 ] , num [ n - rightMax [ i ] - 1 ] = num [ n - rightMax [ i ] - 1 ] , num [ n - i - 1 ] NEW_LINE break NEW_LINE