Problem with code

this is giving me segmentation fault

Hey @Tejas123
In line 12 replace condition by (!st.empty()&& v[i] < v[s.top()])
also add st.push(i) after the end of while loop i.e after line 23 & before line 24
We have to add this index to stack u can dry run on some small example to understand this.
I hope this resolves your query :slight_smile:

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.