KBALANCE [ Starters 12]

problem link → KBALANCE

my submission → submission

please help me out on which test case I am getting WA;

You can check my solution also .

#include <bits/stdc++.h>
using namespace std ;

int main()
{
int T ;
cin >> T ;

while (T--){
    
    int N ; int K ;
    cin >> N >> K ; 
    string s ; 
    cin >> s ;
    int min_operations = 0 ; 
    for(int i  = 0 ; i < N ; i++ ){
        
        if(s[i] == '1'){
            
            int prev_index = i-K  ;
            int next_index = K+i  ;
            
            if((prev_index >= 0 && s[prev_index] == '1') || (next_index <= N  && s[next_index] == '1')){
                continue ;
            }
            
            else if(next_index <= N && s[next_index] != '1'  ){
                s[next_index] = '1' ;
                min_operations++ ;
            }else if((prev_index >= 0 && s[prev_index] != '1') ){
                s[prev_index] = '1' ;
                min_operations++ ;
            }
            else{
                s[i] = '0' ;
                min_operations++ ;
            }
            
        }
    }
    cout<<min_operations<<endl ;
}

return 0;

}