Please help what is error in my code

hi @kailash_01 i have used a similar approach, you can have a look at my code here https://ide.codingblocks.com/s/244095
I have used a vector instead of a map because it is given in the question that the elements are from 1…N.

what is error in my code???

@kailash_01 you are using an unordered map, then accessing the elements like they are present in a ordered way.

my code is correct but giving tle please help me to correct my code

@kailash_01 if you do a dry run you’ll see that might fail for some test cases. Please have a look at the code I gave you, it uses similar logic.

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.