# 【LeetCode刷題】【演算法學習筆記】 2235. Add Two Integers
* 學習時間:2025/01/27 (Mon.)
* **題目連結(美服):**[2235. Add Two Integers](https://leetcode.com/problems/add-two-integers/description/)
* **題目連結(國服):**[2235. 两整数相加](https://leetcode.cn/problems/add-two-integers/description/?envType=study-plan-v2&envId=primers-list)
* Reference: [「新」动计划 · 编程入门](https://leetcode.cn/studyplan/primers-list/) [灵茶山艾府](https://leetcode.cn/u/endlesscheng/)
### A. 解題技術點
---
1. 變數
2. 數學運算
### B. 題目
---
> Given two integers ==num1== and ==num2==, return the sum of the two integers.
### C. 題意(中文)
---
> 給定兩變數 ==num1== , ==num2== 請你回傳兩數之和
### D. 參考程式碼
---
:::spoiler Solution (題解)
``` python3
class Solution:
def search(self, nums: List[int], target: int) -> int:
return num1 + num2
```
:::
:::spoiler Note (筆記)
Extract from: [Leetcode solution](https://leetcode.com/problems/add-two-integers/solutions/4903679/best-solution-in-python-with-explanation/)
**Explanation**
The Solution [class](https://ithelp.ithome.com.tw/articles/10284380) (類別) is defined, which contains a **method** (函式) named ==sum==.
The sum method takes two **parameters** (變數) ==num1== and ==num2==, both of which are integers.
Inside the method, the sum of ==num1== and ==num2== is calculated using the ==+== operator.
The method ==returns== the result of the addition operation, which represents (代表) the sum of the two integers.
The time and space complexities of this solution are both **O(1)**, as the addition operation and memory usage (運用) do not depend on the size of the input integers.
:::