Practice Count K-Reducible Numbers Less Than N
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Hard#3352
LeetCode ProblemCount K-Reducible Numbers Less Than N
Problem Statement
The binary string s represents a positive integer n. A positive integer is k-reducible if replacing it with the number of 1 bits in its binary representation at most k times reaches 1. Count k-reducible positive integers strictly less than n, and return the count modulo 10^9 + 7.
Source: Count K-Reducible Numbers Less Than N on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
s = "111", k = 1
Output
3
# Example 2
Input
s = "1000", k = 2
Output
6
# Example 3
Input
s = "1", k = 3
Output
0
Constraints
1 <= s.length <= 800
s has no leading zeros.
s consists only of the characters '0' and '1'.
1 <= k <= 5
Related LeetCode Problems
Practice more problems similar to Count K-Reducible Numbers Less Than N.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.