3261. Count Substrings That Satisfy K-Constraint II
You are given a binary string
sand an integerk.You are also given a 2D integer array
queries, wherequeries[i] = [li, ri].A binary string satisfies the k-constraint if either of the following conditions holds:
- The number of
0‘s in the string is at mostk.- The number of
1‘s in the string is at mostk.Return an integer array
answer, whereanswer[i]is the number of substrings ofs[li..ri]that satisfy the k-constraint.