Can you tell me what is wrong here , why are test cases 2 and 3 incorrect?

can you please tell me what is wrong here, why test cases 2 and 3 are incorrect?

@Arnav7 hey for this input
5
39
45
40
42
43
your code produces input: 1 2 1 1 1 END
expected output: 1 2 1 2 3 END

now only test case 2 is wrong

@Arnav7 send your modified code

@Arnav7 hey look at this input
5
30
40
35
45
42
your output: 1 2 1 2 1 END
expected output: 1 2 1 4 1 END

why is that 1 4 1 instead of 1 2 1 ?

for 45 all previous numbers are smaller so
3(previous number count) + 1(current number) = 4;

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.