Traverse all array elements in reverse order order == ' G ' we compute next greater elements of every element order == ' S ' we compute right smaller element of every element
for ( int i = n - 1 ; i >= 0 ; i -- ) {