I am not able to figure out the test case for which my code gives the wrong answer. Can anybody help me out on this one. Thanks in advance.
Problem link- https://codeforces.me/contest/1341/problem/C My solution- https://codeforces.me/contest/1341/submission/77847675
while(ind<=pos&&i<=n){ //cout<<i<<" "; if(mp[i]!=ind){ flag=1; break; } i++,ind++; } After the last mp[i] == ind and ind <= pos and i <= n, you will make i + 1. So you will take number, you need. But later you will make one more i + 1. I think problem is here.
UPD: Try to solve this problem with cycle WHILE.
Right, now I understand. Thank you very much.