Attentive.ai Interview Question

Balance paranthesis

Interview Answer

Anonymous

Oct 8, 2020

Just intuitive approach take a variabl x=0, Add 1 to it if you encounter '(' and -1 if ')'. If x<0 anywhere then not balanced Also check if x==0 at the end.