Loop for remaining indexes
while ( stk . size ( ) != 0 ) { maxarr [ stk . size ( ) ] = n - 1 ; stk . pop ( ) ; } Vector < Integer > submax = new Vector < Integer > ( ) ; for ( int i = 0 ; i <= n - y ; i ++ ) {