#1317
Convert Integer to the Sum of Two No-Zero Integers
pupil · 420 · lc easy +25 · verified · 59.1% accepted · 863 likes · top 56%
Description
A No-Zero integer is a positive integer whose decimal representation contains no 0 digit.
Given a positive integer n, find two No-Zero integers a and b such that a + b = n, and return them as [a, b]. Any valid pair is acceptable; the input guarantees at least one exists.
Example 1:
Input: n = 2
Output: [1,1]
Explanation: Let a = 1 and b = 1.
Both a and b are no-zero integers, and a + b = 2 = n.
Example 2:
Input: n = 11
Output: [2,9]
Explanation: Let a = 2 and b = 9.
Both a and b are no-zero integers, and a + b = 11 = n.
Note that there are other valid answers as [8, 3] that can be accepted.
Code
1
2
3