1317. Convert Integer to the Sum of Two No-Zero Integers

Updated: 2024-03-12
1 min read
[]

On This Page

LeetCode problem 1317

class Solution:
    def getNoZeroIntegers(self, n: int) -> List[int]:
        def f(x):
            while x:
                if x % 10 == 0:
                    return False
                x //= 10
            return True

        for a in range(1, n):
            b = n - a
            if f(a) and f(b):
                return [a, b]