One of the test cases failed. help me fix my code

I submitted the code for this question. 3 out of 4 test cases passed, please help me correct my code that all the test cases pass.

@Syed-Siddiqui-2497215583854102
Hi for test case:-
6
30 50 37 38 35 40
your ans :- 1 2 1 2 1 2 END
correct :- 1 2 1 2 1 4 END

So try to handle this case, you have to modify the approach!

I misinterpreted the question. I thought if once the stock span fall back to 1, then it has to be start with 1 only but the test case told by you cleared the image. Thank You, my problem has been resolved.

@Syed-Siddiqui-2497215583854102 bro mark ya doubt resolved and rate full!
Happy coding!