Your Dashboard
Interview Coaching
Learn
System Design
ML System Design
Code
Behavioral
Salary Negotiation
Interview Guides
Search
⌘K
Get Premium
Leetcode 3261. Count Substrings That Satisfy K-Constraint II
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.
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
All Regions
Comments
Hello Interview Premium
Your account is free and you can post anonymously if you choose.