less than 1 minute read

Problem Statement

leetcode problem link

Brute Force approach [Accepted]

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

Approach: Enumeration

class Solution:
    def getNoZeroIntegers(self, n: int) -> List[int]:
        for A in range(1, n):
            B = n - A
            if "0" not in str(A) + str(B):
                return [A, B]
        return []