Stock span(stack challenges)

getting 3/4 test cases passed.Please help

Hello @sarthak051999,

Your code is failing for test cases like:
5
30 35 40 38 40
Expected Output:
1 2 3 1 5 END
Your Output:
1 2 3 1 2

Hope, this would help.
Give a like if you are satisfied.

what should be the correct approach
?

Hello @sarthak051999,

I can share what i have applied. It’s the same as what you have studied in your course: