A utility function to reverse an array from index 0 to n - 1
def reverse ( arr , n ) : NEW_LINE INDENT l = 0 NEW_LINE r = n - 1 ; NEW_LINE while ( l < r ) : NEW_LINE INDENT arr [ l ] , arr [ r ] = ( arr [ r ] , arr [ l ] ) ; NEW_LINE l += 1 NEW_LINE r -= 1 NEW_LINE DEDENT DEDENT