---
# System prepended metadata

title: '【LeetCode】Javascript - #415 Add Strings'
tags: [leetcode, javascript]

---

###### tags: `leetcode`, `javascript`
# 【LeetCode】Javascript - #415 Add Strings

---
### 題目：
Given two non-negative integers, num1 and num2 represented as string, return the sum of num1 and num2 as a string.

You must solve the problem without using any built-in library for handling large integers (such as BigInteger). You must also not convert the inputs to integers directly.

---

### 大概翻譯：
給定兩個非負的整數，num1及num2為字串，返回num1和num2的和為字串

您必須在不使用任何內寘庫來處理大整數（例如BigInteger）的情况下解决該問題。 也不能將輸入直接轉換為整數。

---
例如：
```javascript=
Input: num1 = "11", num2 = "123"
Output: "134"

Input: num1 = "456", num2 = "77"
Output: "533"
```

---
最簡單的方式就是
```javascript=
var addStrings = function(num1, num2) {
    sum_int = BigInt(num1) + BigInt(num2)
    return sum_int.toString()
};
```
![](https://i.imgur.com/L5Vhw3J.png)
看起來很不錯 :thinking_face: 
但題目又有限制不能使用BigInt，只好改變作法

---

...
...待補

---

*新手工程師的筆記，純粹記錄學了些啥東西
如果有前輩高人讀了我的文，文中有任何錯誤再麻煩指教指教*