Stock span question doubt


PL tell modifications to be done in the code as I am not getting the desired output

Hello @ayush15goel,

What i have observed, you code is printing 0 for the first day for all testcases.
You are required to store span as 1 for the first day.

Due to this problem, the following values have 1 less span value than it should actually have:
example:
5
30 35 40 38 35
Expected Output:
1 2 3 1 1 END
Your Output:
0 1 2 1 1 END

Correct this.
If you still face problem, feel free to ask.

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

sir pl tell corrections in the code.I am not able to figure out how to correct the output.

Sure,

I have modified your code. You can check here:

I have commented all the modifications with reason.

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