Concatenate Digit-wise Sums
Problem statement
For this exercise, use the callable contract below.
You are given two non-empty strings a and b consisting of decimal digits.
Right-align the strings. For each aligned position, add the corresponding digits. If one string has no digit at that position, use the digit from the other string as the sum for that position.
Return a string formed by concatenating these per-position sums from the leftmost aligned position to the rightmost. A sum such as 18 contributes both characters 1 and 8; there is no carry between positions.
Function
concatenateDigitSums(a: String, b: String) → StringExamples
Example 1
a = "99"b = "99"return = "1818"The two aligned positions each contain 9 + 9 = 18. Concatenating the two sums gives "1818".
Example 2
a = "11"b = "9"return = "110"The leftmost position contains only 1, and the rightmost position has 1 + 9 = 10. Concatenating 1 and 10 gives "110".
Constraints
1 <= a.length, b.length <= 105aandbcontain only decimal digits and each represents a positive integer.- Digits are aligned from the right, and every position is summed independently without carrying.