Stock span problem - what's wrong in my code?

Try the given test case, your solution gives wrong ans for that as well. The reason is that you are just popping the elements from stack without checking any condition.
Screenshot%20from%202019-10-10%2000-54-59

see this example^ which is also explained in video, in this if we are at 80, if we get any value greater 80, then we’ll need to stop at 100, but if the value is smaller than 80 then we stop at 80 itself, as in example we get 60 i.e. <80 therefore we stop at 80 hence ans is 1
You are popping without checking, you have to pop when
price[i th day] > prices[stack’s top element]

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.