Whats wrong here?? HELP!!

It’s a question of starter 14
question - Contest Page | CodeChef
My solution - Solution: 51843613 | CodeChef

Consider the test input:

2 0
1 Like

understood …I have wrongly handled the case of k = 0. Thank You very much. Now I can sleep

1 Like

I implement it and found that I have handled case n=k wrongly but after implementing
there still some problem. can u check??sorry for trouble. solution link ::Solution: 51852019 | CodeChef

Consider the input

3 0

output is
I guess its correct. is it??

Number of indices i such that A_i = i is exactly K

In your case, i=2 will satisfy the condition and hence the number of indices will be 1, but it should be 0

One valid solution would be 2 3 1

1 Like

yup…got it … thanks

learnt to cover all the corner cases