Problem of The Day: Convert Integer to the Sum of Two No-Zero Integers
Problem Statement
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 []