0 and 1 (with no leading zeros). For instance, 1, 10 and 1101 are binary-looking, while 12 and 2001 are not.
You are given a positive integer as a string number. Return the smallest count of binary-looking numbers that add up to number. The same number may be used more than once.number="46" → 6
46 = 11 + 11 + 11 + 11 + 1 + 1, six addends. Fewer is impossible: each addend adds at most 1 to the last digit.
number="1010" → 1
The number itself uses only 0s and 1s, so one addend is enough.
number="30719" → 9
number contains digits onlynumber has no leading zeronumber="46"
6
Run checks the first 3 tests in your browser. Submit checks all 75 tests on the server, hidden ones included.