This question evaluates proficiency in string-based arithmetic, digit-wise addition, carry propagation, and management of arbitrarily large non-negative integers without converting entire strings to native numeric types.
You are given a helper function:
addDigits(a, b) -> (sumDigit, carry)
a
and
b
are
single decimal digits
(characters
'0'
…
'9'
or integers 0…9).
a + b
and the
carry
(0 or 1).
addDigits(7, 8) -> (5, 1)
.
Implement addStrings(num1, num2) -> string that returns the decimal string representing num1 + num2.
num1
and
num2
are
non-negative integers
represented as strings (no leading
+
/
-
).
addDigits
helper for digit-wise addition.
addStrings("11", "123") = "134"
addStrings("999", "1") = "1000"
addStrings("0", "0") = "0"