Given two non-negative integers represented as strings, return the sum of the two numbers as a string. Compute the result by simulating digit-by-digit addition rather than converting the entire strings to a numeric type. Return null if either input is null.
Examples:
Input: num1 = '11', num2 = '22'
Output: '33'
Explanation: 11 + 22 = 33
Input: num1 = '456', num2 = '77'
Output: '533'
Explanation: 456 + 77 = 533, with carrying required
Input: num1 = '1', num2 = '999'
Output: '1000'
Explanation: 1 + 999 = 1000, result has more digits than either input
Input: num1 = '0', num2 = '0'
Output: '0'
Explanation: Zero plus zero is zero
Input: num1 = null, num2 = '5'
Output: null
Explanation: Null input returns null
Apex Code Editor
Welcome to Lightning Challenge!
How It Works
- • Write your solution in the code editor
- • Connect your Salesforce org to test
- • Submit to check if your solution passes
- • Use hints if you get stuck
Contest Alert
🏆 #CodeEveryDay September 2026 (Sep 16–30)Sponsored by FLXBL
Contest runs September 16 - 30. Complete challenges to climb the leaderboard!
Prizes 1 & 2: Salesforce certification exam voucher — won by random drawing, where every point is a ticket. see all prizes
Only the 15 daily challenges shown during this contest count toward points. Earlier dailies don't carry over.