You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Given two non-negative integers, num1 and num2 represented as string, return the sum of num1 and num2 as a string.
6
+
7
+
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.
8
+
9
+
Example 1:
10
+
Input: num1 = "11", num2 = "123"
11
+
Output: "134"
12
+
13
+
Example 2:
14
+
Input: num1 = "456", num2 = "77"
15
+
Output: "533"
16
+
17
+
Example 3:
18
+
Input: num1 = "0", num2 = "0"
19
+
Output: "0"
20
+
21
+
Constraints:
22
+
1 <= num1.length, num2.length <= 104
23
+
num1 and num2 consist of only digits.
24
+
num1 and num2 don't have any leading zeros except for the zero itself.
25
+
*/
26
+
27
+
classSolution
28
+
{
29
+
public:
30
+
string addStrings(string num1, string num2)
31
+
{
32
+
reverse(num1.begin(), num1.end());
33
+
reverse(num2.begin(), num2.end());
34
+
35
+
string ans = "";
36
+
int carry = 0, i = 0;
37
+
38
+
while (i < num1.size() || i < num2.size() || carry)
| 6. |[N-ary Tree Level Order Traversal](https://leetcode.com/explore/challenge/card/august-leetcoding-challenge-2021/613/week-1-august-1st-august-7th/3871/)|[cpp](./06.%20N-ary%20Tree%20Level%20Order%20Traversal.cpp)|
0 commit comments