Why ny code is giving the segmentation fault

Hi @kailash_01, there is one small mistake in your code , at line 24, you are doing
while(a[i]>s.top()&&!s.empty()) i.e accessing s.top( ) first then checking if s is empty or not
but it should be opposite i.e. while(!s.empty()&&a[i]>s.top()).

I have made the changes you can refer the code here :-

In case of any doubt feel free to ask :slight_smile:
If you got the answer then mark your doubt as resolved