Guys pls help...getting segmentation fault on ONP

Here is my



Pls tell me what am i doing wrong because of which I am getting this SIGSEV.

the fault is in the following segment:


During the running of the program, somehow such a situating is occurring that this if statement is entered even when stack is empty, hence when s.pop() executes, you are trying to access unallocated memory, thus the SIGSEGV. So to take care of this, the if condition should be: if(a[i]==')'&&(!s.empty())).
Even after correcting this, the logic of your code is incorrect. Try to figure that out yourself :slight_smile:

Thanks for ur ans…indeed that was the mistake but my logic is correct. I have missed ‘/’ operator in my if cond. After fixing, got AC on spoj and Codeshef.

Really appreciate ur effort :slight_smile: :slight_smile:

you’re welcome:)
oh, i didn’t see the logic of the code properly, just the s.pop() part :stuck_out_tongue: