Convert Integer to the Sum of Two No-Zero Integers

Problem Id: 1317 Difficulty: Easy Tag: Math


Intuition

The range of n is [2, 10 ^ 4]. So we could solve this problem simply by brute force.

Solution


class Solution:
    def getNoZeroIntegers(self, n: int) -> List[int]:
        for i in range(1, n):
            if '0' not in str(i) and '0' not in str(n - i):
                return [i, n - i]