Convert Integer to the Sum of Two No-Zero Integers - Problem

A 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.

Input & Output

Example 1 — Basic Case
$ Input: n = 2
Output: [1,1]
💡 Note: 1 + 1 = 2. Both 1 and 1 are no-zero integers (contain no digit 0)
Example 2 — Larger Number
$ Input: n = 11
Output: [2,9]
💡 Note: 2 + 9 = 11. Both 2 and 9 contain no zeros. Note: [1,10] would be invalid since 10 contains 0
Example 3 — Three Digit Number
$ Input: n = 101
Output: [1,100]
💡 Note: Wait, 100 contains zeros! Better solution: [11,90] - but 90 has 0. Actually [99,2] works: 99 + 2 = 101

Constraints

  • 2 ≤ n ≤ 104

Visualization

Tap to expand
Convert n=11 to Sum of Two No-Zero Integers11Input: n2No zeros ✓9No zeros ✓Split into two parts2 + 9 = 11 ✓Output: [2, 9]
Understanding the Visualization
1
Input
Given integer n = 11
2
Process
Find a, b where a + b = n and neither contains 0
3
Output
Return [a, b] = [2, 9]
Key Takeaway
🎯 Key Insight: Start with the simplest split and adjust incrementally to avoid zeros in both numbers
Asked in
Amazon 15 Google 12 Microsoft 8
15.2K Views
Medium Frequency
~15 min Avg. Time
428 Likes
Ln 1, Col 1
Smart Actions
💡 Explanation
AI Ready
💡 Suggestion Tab to accept Esc to dismiss
// Output will appear here after running code
Code Editor Closed
Click the red button to reopen