+If each deci-binary number's digits are only 0 or 1, summing k such numbers column-wise (digit-wise) yields in each digit position a value between 0 and k (inclusive). To form the input number n, for every digit d in n we need k >= d (because the sum of the bits in that column must equal the digit d). That suggests the minimum k must be at least the maximum digit in n. Can we always achieve k equal to that maximum digit? Intuitively yes: we can construct max_digit deci-binary numbers by distributing 1s across them so each column sums to the required digit. So the answer should be the maximum digit in the string. No need for complicated DP or greedy construction beyond this observation.
0 commit comments