Search
⌘K
Get Premium
Leetcode 3258. Count Substrings That Satisfy K-Constraint I
Count the number of substrings of a binary string s such that either the number of 0s or the number of 1s in the substring is ≤ k. With n ≤ 50 this can be solved by enumerating substrings and using prefix counts or a two-pointer scan to check the k-constraint efficiently.
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.