Skip to main content

Sum of Two Character Array Integers

easy
Software engineer

Given two character arrays, each representing a signed base-10 integer (with an optional leading '-' for negative values), write a function that parses each array into its corresponding integer and returns the sum of these two integers.

Constraints

  • Each input array length is between 1 and 4.
  • Parsed values are within range $[-100, 100]$.
  • Valid characters are '0' - '9' and an optional leading '-'.

Example 1

Input

num1 = ["1","2"], num2 = ["5"]

Output

17

Explanation

The first array ["1","2"] represents the integer 12. The second array ["5"] represents the integer 5. The sum is 12 + 5 = 17.

Example 2

Input

num1 = ["-","1","0"], num2 = ["4"]

Output

-6

Example 3

Input

num1 = ["0"], num2 = ["0"]

Output

0

Constraints

  • 1 <= num1.length, num2.length <= 4
  • Valid characters: '0'-'9', '-'
  • Parsed integers are within [-100, 100]

Screening

ArrayMathSimulationString
Language
Code editor loads in the browser.

Output

Input

["1","2"]
["5"]

Expected

17

Your output

Run to see your output.