Given an integer n
. No-Zero integer is a positive integer which doesn't contain any 0 in its decimal representation.
Return a list of two integers [A, B]
where:
-
A
andB
are No-Zero integers. A + B = n
It's guarateed that there is at least one valid solution. If there are many valid solutions you can return any of them.
Method: 暴力解法
Time: O(n)
Space: O(1)
class Solution: def getNoZeroIntegers(self, n: int) -> List[int]: a = 1 b = n - a while a <= b: if '0' in str(a) or '0' in str(b): a += 1 b -= 1 else: break return [a, b]