0415. Add Strings
Easy | String + Math | 28 ms (97.36%), 14.2 MB (83.13%)
Source: LeetCode - Add Strings GitHub: Solution / Performance
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.
Sum each character reversely by index indicators starting from the end.
Since two strings might have different lengths, we need to take care of the condition when either one of strings meets the beginning first.
Last updated