Function to display the resultamt stack
void display ( stack < int > & res ) { int N = res . size ( ) ; string s = " " ; while ( ! res . empty ( ) ) { s = to_string ( res . top ( ) ) + s ; res . pop ( ) ; } cout << s << endl ; }