it is showing segmentation fault.
this is the link to my code…
Can you help me figure out why my code is not working
@Akshita99, you have declared ans array of the size n and then in line 29, 31, 35, when you are doing ans[s.top().second] it raise runtime error as s takes value from array and array can have values greater than n so using it as an index for ans which can take index value E (0,n-1) raises error.
also, always remember whenever you are using s.top() or q.front() in the while loop condition of if condition you should always check if s.empty() is false ,eg in line no’ , 19,25,35
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.