Partitioning Into Minimum Number Of Deci-Binary Numbers
A decimal number is called deci-binary if every one of its digits is `0` or `1` and it has no leading zeros, for example `101` and `1100`. Given a string `n` that holds a positive decimal integer, return the minimum number of positive deci-binary numbers that sum to `n`.
30:00
Partitioning Into Minimum Number Of Deci-Binary Numbers
A decimal number is called deci-binary if every one of its digits is 0 or 1 and it has no leading zeros, for example 101 and 1100. Given a string n that holds a positive decimal integer, return the minimum number of positive deci-binary numbers that sum to n.
Example 1:
Input: {"n":"32"}
Output: 3
Constraints:
1≤n.length≤105
n consists of only digits.
n does not contain any leading zeros and represents a positive integer.
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"n":"32"}
best = 0
2 digits
9
8
7
6
5
4
3
2
1
3
2
A deci-binary number adds at most 1 to each digit position, so a digit d needs at least d of them. Find the largest digit of 32.