What wrong in this code

@Adityakumar3112
hey actually your logic is wrong. Consider this testcase
5
30
40
35
45
42
your code prints “1 2 1 2 1 END” but the correct output is " 1 2 1 4 1 END"
All the element before 3rd index are smaller that 45(ar[3]), thus it’s ans is 4

@Adityakumar3112
I think you got the logic and successfully solved this question. please mark it as resolved.

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.