Stock Span Problem

One testcase is not getting passed.
Please help me to find the mistake in my code

The link to the code is :- https://ide.codingblocks.com/s/233391


i have changed the logic, what it is doing is that it is at any stage keeping the largest element on the top of the stack so if current element is greater then it’s span is that of all of previous so it pops all the elements till it is the greatest element
at the end if the stack is empty, it’s span is i+1 that is it’s index but +1 for 1 based indexing
or it is simply it’s current index - the index of the greatest element i.e. element at the top of the stack

Thanks a lot for the help!

hey @krikhi if your doubt is solved, please mark it as resolved