Available question text
Given a binary string s and integer k, for each query [l,r] count substrings of s[l..r] whose number of 0's is ≤ k or whose number of 1's is ≤ k. The challenge is to answer up to 1e5 range queries on a string of length up to 1e5, so you need efficient preprocessing (sliding-window/prefix-sum and combinatorial substring counting) to avoid per-query scanning.
Related questions
Continue with questions that share topics or the same question type.
Sources · 1 reference
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 1 record
No company association
Leetcode 3261. Count Substrings That Satisfy K-Constraint II
Reported date not specified · 0 source reports
Source snapshot: Nov 12, 2026
View source