Add Two Numeric Strings with Carry
Updated
Problem statement
You are given two strings, a and b, representing nonnegative decimal integers. Return their decimal sum as a string.
Perform digit-by-digit addition with carry; the inputs may be too large for fixed-width numeric types.
Function
addNumericStrings(a: String, b: String) → StringExamples
Example 1
a = "999"b = "1"return = "1000"Adding the final digits produces a carry through all three nines.
Example 2
a = "123"b = "789"return = "912"Right-to-left addition gives units 2, tens 1, and hundreds 9.
Constraints
1 <= a.length,b.length <= 10000- Both inputs contain only decimal digits.
- Neither input has a leading zero unless it equals
"0".
More ZipRecruiter Onsite Interview questions
- Restaurant Vote LeadersPHONE SCREEN · ONSITE INTERVIEW · Seen Feb 2026
- Sliding Window Rate LimiterOA · ONSITE INTERVIEW · Seen Oct 2022
- Sort an Integer Array in Ascending OrderOA · ONSITE INTERVIEW · Seen Apr 2022
- Classify an Alien Dictionary OrderingPHONE SCREEN · ONSITE INTERVIEW · Seen Mar 2022
- Add Numbers Stored in Four-Digit ChunksONSITE INTERVIEW · Seen Nov 2021
- Expand Decimal Digits into Runs of OnesONSITE INTERVIEW · Seen Nov 2021
- Solve a Sudoku BoardONSITE INTERVIEW · Seen Aug 2021
- Validate a Sudoku BoardONSITE INTERVIEW · Seen Aug 2021
- Iterate Ragged Integer Lists VerticallyONSITE INTERVIEW · Seen May 2017
- Min StackONSITE INTERVIEW · Seen Feb 2017
Similar questions at other companies
- Add Two Numbers Given as Digit ArraysCapital One · ONSITE INTERVIEWCapital One interview questions
- Iterate Canonical IPv6 AddressesOpenAI · ONSITE INTERVIEWOpenAI interview questions
- Nth Staged License PlateGoogle · ONSITE INTERVIEWGoogle interview questions
- Add Decimal Strings ExactlyMeta · PHONE SCREEN · ONSITE INTERVIEWMeta interview questions
- Subtract Two Large Number StringsStackAdapt · PHONE SCREENStackAdapt interview questions
- Fair Coin from a Biased CoinAnthropic · PHONE SCREENAnthropic interview questions
- Add Two Integers Given as StringsJane Street · PHONE SCREENJane Street interview questions
- Fizz and Buzz Words From 1 to nDocuSign · PHONE SCREENDocuSign interview questions
- Fizz BuzzBloomberg LP · PHONE SCREENBloomberg LP interview questions
- Get Max DeletionsJP Morgan Chase · OAJP Morgan Chase interview questions