How is my code working for even no of inputs?


It’s working fine for both even and odd, I get it how it is working for odd but when
1 2 3 3 2 1
iterators are at 3 and 3, what happens after that?

so basically loop vha end ni hota because i != j… so it continues… and since its a palindrome elements match hote rhte hai…
so dont worry move ahead with other questions…

so shouldn’t it be an infinite loop since vo end he ne ho rha?, why is this isn’t an infinite one?

how would it be a infinite loop… whenever u have these kind of doubts try to dry run… just put cout statements and check… loop will stop…

so, when n = 6; cnt = 6 which means that the iterators of list in STL only iterates to the end and begin of list, so when the iterators goes go out of scope, the loop ends, right?

yes… its very much evident… hope ur doubt is cleared

Got it, thanks for ur help

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.