Skip to content

Files

Latest commit

author
Shuo
Feb 16, 2022
ce6b544 · Feb 16, 2022

History

History

convert-integer-to-the-sum-of-two-no-zero-integers

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Feb 16, 2022

< Previous                  Next >

No-Zero integer is a positive integer that does not contain any 0 in its decimal representation.

Given an integer n, return a list of two integers [A, B] where:

  • A and B are No-Zero integers.
  • A + B = n

The test cases are generated so that there is at least one valid solution. If there are many valid solutions you can return any of them.

 

Example 1:

Input: n = 2
Output: [1,1]
Explanation: A = 1, B = 1. A + B = n and both A and B do not contain any 0 in their decimal representation.

Example 2:

Input: n = 11
Output: [2,9]

 

Constraints:

  • 2 <= n <= 104

Related Topics

[Math]

Hints

Hint 1 Loop through all elements from 1 to n.
Hint 2 Choose A = i and B = n - i then check if A and B are both No-Zero integers.