Reverse the substring starting after the last encountered opening bracket till the current character
else if ( str [ i ] == ' ' ) { let A = [ ... str ] reverse ( A , st [ st . length - 1 ] + 1 , i ) ; str = [ ... A ] ; st . pop ( ) ; } }