Test cases( Stock Span)

Here is the code:


The 2nd test cases is giving wrong ans

Hello @Codecracaker532,

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

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

here is the code: https://ide.codingblocks.com/s/231104 the 2nd test case is still giving wrong ans. Please tell what is the problem?

Hello @Codecracaker532,

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

shouldn’t the length of the array be 6 in test case

I changed the code. It is working for the test case you sent but still giving wrong ans in the 2nd test case. Here is the code

Hello @Codecracaker532,

Sorry, for replying late. I was sick for few days.

BTW, I have corrected your code:


Refer to comments for better understanding.

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

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.