ASP - Editorial

Check the way you read the data…

See here an example where your code fails:

Sorry. Your code is wrong.
It fails with:

1

6

1 10 2 11 3 14

I don’t check why you get TLE, but your algo is wrong. You check the values against {1,2,3…,n}, but it is not said that the Ai are a permutation of {1,…n}.

@beroul give me some test cases where i am failing and why my algo is wrong

@shashi jey
Your solution works only if the numbers are from 1 to N.
But the input can contain any numbers.
Ex: N = 4 and A[]={1 3 8 6}.

Check my solution dude , I didn’t even used fast i/o!

@anh1l1ator

Sorry, but your solution fails for:

1

5

1 0 4 2 5

1 Like