Lunski's Clutter

This is a place to put my clutters, no matter you like it or not, welcome here.

0%

1317. Convert Integer to the Sum of Two No-Zero Integers

Given an integer n. No-Zero integer is a positive integer which doesn’t contain any 0 in its decimal representation.

Return a list of two integers [A, B] where:

A and B are No-Zero integers.
A + B = n
It’s guarateed that there is at least one valid solution. If there are many valid solutions you can return any of them.

Example 1:

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

Example 2:

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

Example 3:

1
2
Input: n = 10000
Output: [1,9999]

Example 4:

1
2
Input: n = 69
Output: [1,68]

Example 5:

1
2
Input: n = 1010
Output: [11,999]

要把一個整數拆成2整數和,沒有限制怎麼拆(那不是拆1出來就好)直接跑也過了,但總覺得怪,在看其他人怎麼做之後選了比較好懂的做法,簡單來說就是找可以拆的數字,再格式化輸出,學到了格式化輸出。


如果你覺得這篇文章很棒,請你不吝點讚 (゚∀゚)

Welcome to my other publishing channels