tack to keep track of max element
static Stack < Integer > trackStack = new Stack < Integer > ( ) ; static void push ( int x ) { mainStack . push ( x ) ; if ( mainStack . size ( ) == 1 ) { trackStack . push ( x ) ; return ; }