please answer this..

tell me where m i wrong please and if there is any better way to solve this…here is my solution for problem code CGEEK01

@harshitbhalla

You calculated k as,

k=r-(n-(j+1));

You could have done,

k=1+(j+r)%n;

If you still face any problem,

Here’s the link to my code.

@shawnfrost thanks for answering this buddy :stuck_out_tongue: but dude can you tell me why is k=r-(n-(j+1)); wrong.

@harshitbhalla See,

It is obvious that the minimum value of j will be 2 i.e. String would be 111…so on,

so,we have k=r+3-n;

Given that,1 ≤ r ≤n implies 4-n ≤ k ≤ 3

and it’s wrong as you know, 1 ≤ k ≤ n.