Partitioning into minimum number of deci binary numbers
November 30, 2022
greedyProblem URL: Partitioning into minimum number of deci binary numbers
Assume max digit in n is x, because deci-binary only contains 0 and 1, we need at least x numbers to sum up a digit x. So we can just find the max digit in n and return it.
class Solution:
def minPartitions(self, n: str) -> int:
return int(max(n))
Time complexity: O(n)
Space complexity: O(1)