KBalance(what is wrong with my code)

Continuing the discussion from KBALANCE - Editorial:

this is link to my code:- CodeChef: Practical coding for everyone

Consider the test case:

1
9 2
000100010

Correct output: 1
Output by your solution: 2

Its optimal to flip the ‘0’ at index 6 (1 based indexing) to get 2-Balanced string.

1 Like

thanks man for ur time!!
i figured it out

even now getting wa
https://www.codechef.com/viewsolution/51472331