← 返回 bytedance 的题目列表Add Two Signed Integer Strings
类型:online_judge
Given two character arrays (or strings) a and b representing decimal integers, where either array may start with a minus sign '-', return their algebraic sum as a normalized decimal string.
Requirements:
Except for an optional leading '-', every character is a digit from '0' to '9'.
The integers can be very large, so do not convert the entire input into a built-in numeric type.
The result must not contain leading zeros. For example, "00012" is treated as "12", and "-00012" as "-12".
Zero must be returned as "0", never "-0".
Example 1
Input: a = "123", b = "456"
Output: "579"
Example 2
Input: a = "-123", b = "456"
Output: "333"
Example 3
Input: a = "123", b = "-456"
Output: "-333"
Example 4
Input: a = "-999", b = "999"
Output: "0"
Constraints: 1 <= len(a), len(b) <= 10^5.
Example
Input
123
456
Output
579