And one important thing..
- Code: Select all
while(stack[k-1]!='(' && k>0)
Now if k=0 then your code first checks stack[-1], then it checks k>0. Your code will try to access negative index. So, better to use
- Code: Select all
while(k>0 && stack[k-1]!='(')
Hope these help.


