I am trying to solve this problem and I am not able to understand the editorial that why dp[0][i]=min(dp[1][i-a]+sum-of-whites(i-a+1,i)) dp[1][i]=min(dp[0][i-a]+sum-of-blacks(i-a+1,i)) where a belongs to [x,y] Editorial Link :- Editorial Question Link :- Question