Link to question :- Contest Page | CodeChef

Here is my code:-

#include <bits/stdc++.h>

using namespace std;

int main() {

// your code goes here

long long int t,n;

cin>>t;

while(t–){

cin>>n;

long long int a[n],res=0;

for(long long int i=0;i<n;i++)

cin>>a[i];

for(long long int i=0;i<n;i++){

if(a[i]==1){

for(long long int j=i+1;j<n;j++){

if(a[j]-a[j-1]!=1)

break;

else

res=max(res,a[j]);

}

}

}

cout<<res<<endl;

}

return 0;

}

Please can anyone rectify my error in the code as I’m unable to. The sample test cases are also working fine.