「无零整数」是十进制表示中 不含任何 0 的正整数。
给你一个整数 n
,请你返回一个 由两个整数组成的列表 [A, B]
,满足:
A
和B
都是无零整数A + B = n
题目数据保证至少有一个有效的解决方案。
如果存在多个有效解决方案,你可以返回其中任意一个。
1317. 将整数转换为两个无零整数的和 – 力扣(Leetcode)


思路:
遍历符合题意得元素即可。
python3实现:
class Solution:
def getNoZeroIntegers(self, n: int) -> List[int]:
tmp = 1
while 1:
if "0" not in str(n-tmp) and "0" not in str(tmp):
return [tmp, n-tmp]
else:
tmp += 1
