Function to reverse an array . An array can be reversed in O ( n ) time and O ( 1 ) space .
static void reverse ( int arr [ ] , int l , int r ) { if ( l < r ) { arr = swap ( arr , l , r ) ; reverse ( arr , ++ l , -- r ) ; } }