My answer is same but still on submit it showing all test cases wrong answers

Here is the link the link of my code:

Please Someone rectify

Have debugged your code here, It will still not pass 2 test cases because of the constraints


Try to do it this way to those constraints, rest everything is fine with your code.

@mr.encoder

Can You please explain me what was mistake in my code.

Why do you use struct instead of class,is there is any reason?

Yes , sure. Just have add count ++ in else instead of if

No, you can do it via class also. Use of struct, not necessary

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.