Problem Statement
Given two non-negative integers represented as strings, return their sum, also as a string.
You must not use any BigInteger library or convert the entire input to an integer directly (the numbers can be arbitrarily large — beyond 64-bit range).
Constraints
1 <= num1.length, num2.length <= 10^4- Both strings contain only digits
0-9 - No leading zeros (except the number "0" itself)
- Cannot use built-in big-number libraries
Example
Input: num1 = "9999999999999999999", num2 = "1"
Output: "10000000000000000000"
Input: num1 = "456", num2 = "77"
Output: "533"
What the Interviewer Expects
- Simulate grade-school addition — process digits from right to left.
- Track carry — sum each pair of digits + carry, append
sum % 10, carrysum / 10. - Handle different lengths — use pointers and treat missing digits as 0.
- Final carry — don't forget to append a leading 1 if carry remains.
- Build result efficiently — append to a list/StringBuilder and reverse at the end (avoid O(n²) string concatenation).
Follow-ups
- How would you extend this to multiply two large numbers as strings?
- How would you handle subtraction (including negative results)?
- What if the numbers are in a base other than 10 (e.g., hexadecimal)?
- How would you handle decimal points (floating-point strings)?