#415

Add Strings

pupil · 440 · lc easy +26 · verified · 52.1% accepted · 5,436 likes · top 42%

play →

Description

You are given two non-negative integers as strings num1 and num2. Add them together and return the result as a string. You may not cast either string to an integer type directly, nor use any big-integer library.

Example 1:

Input: num1 = "11", num2 = "123"
Output: "134"

Example 2:

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

Example 3:

Input: num1 = "0", num2 = "0"
Output: "0"

Code

1
2
3