Files
coding-practice/problems/1317-convert-integer-to-the-sum-of-two-no-zero-integers/README.md

66 lines
1.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# [1317] Convert Integer To The Sum Of Two No Zero Integers
## 題目資訊
- **難度**: Easy
- **標籤**: Math
- **題目連結**: [LeetCode](https://leetcode.com/problems/convert-integer-to-the-sum-of-two-no-zero-integers/)
- **練習日期**: 2025-09-08
## 題目描述
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.
## 解題思路
### 初步分析
- 這題主要考察什麼概念?
迴圈遍歷 + 數字位數檢查
- 有什麼關鍵限制條件?
1. 兩個數都必須是正整數
2. 兩個數的十進制表示都不能包含數字 0
3. 兩個數相加必須等於 n
- 預期時間/空間複雜度?
### 解法概述
**解法**:
- 思路:
1. 從 i = 1 開始遍歷到 n-1
2. 對每個 i檢查 i 和 (n-i) 是否都不包含數字 0
3. 找到第一個滿足條件的組合就返回
- 時間複雜度O(n)
- 空間複雜度O(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.
```
### 邊界情況
2 <= n <= 10^4
## 學習筆記
### 今天學到什麼?
-
### 遇到的困難
-
### 改善方向
-
### 相關題目
---
**總結**: 這題的核心概念是...,適合練習...技巧。