when i run it on ideone the code runs successfully but spoj gives me runtime error sigsegv can somebody tell what is wrong with my code ideone.com/KOy4F0
SIGSEGV is an error caused by an invalid memory reference or segmentation fault.
ReCheck your while loop
while(s.top() != 'N'){
s.pop();
out += s.top();
}
When there is only 1 element in āsā i.e. for the last iteration
and after you
s.pop()
āsā becomes empty.
thus in the next line
out+=s.top()
s.top() points to an invalid memory.
Hope this helps.
If this solution solves your problem kindly Accept it using the tick option below the downvote button. Happy coding