Failing 1 test case

code - https://ide.codingblocks.com/s/387478

@anubhavb0011 your logic is fine but using map is giving you wrong answer for bigger size of n,try to think of an approach with optimized space.

but still it is working in o(n) so whats the problem with maps

it is mentioned in the problem statement that you to solve it in o(1) space complexity.

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.