WA for two test cases

could you help me in finding… why this code is not working for two test cases.

hi @dalvimangesh000, check this:
5 5
1 2
2 3
3 4
4 2
2 1
ans is 4

1 Like

thanks, got it where i was missing.

1 Like

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.