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


You calculated k as,


You could have done,


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.