415. Add Strings Easy
1/**
2 * [415] Add Strings
3 *
4 * Given two non-negative integers, num1 and num2 represented as string, return the sum of num1 and num2 as a string.
5 * You must solve the problem without using any built-in library for handling large integers (such as BigInteger). You must also not convert the inputs to integers directly.
6 *
7 * Example 1:
8 *
9 * Input: num1 = "11", num2 = "123"
10 * Output: "134"
11 *
12 * Example 2:
13 *
14 * Input: num1 = "456", num2 = "77"
15 * Output: "533"
16 *
17 * Example 3:
18 *
19 * Input: num1 = "0", num2 = "0"
20 * Output: "0"
21 *
22 *
23 * Constraints:
24 *
25 * 1 <= num1.length, num2.length <= 10^4
26 * num1 and num2 consist of only digits.
27 * num1 and num2 don't have any leading zeros except for the zero itself.
28 *
29 */
30pub struct Solution {}
31
32// problem: https://leetcode.com/problems/add-strings/
33// discuss: https://leetcode.com/problems/add-strings/discuss/?currentPage=1&orderBy=most_votes&query=
34
35// submission codes start here
36
37impl Solution {
38 pub fn add_strings(num1: String, num2: String) -> String {
39 String::new()
40 }
41}
42
43// submission codes end
44
45#[cfg(test)]
46mod tests {
47 use super::*;
48
49 #[test]
50 fn test_415() {
51 }
52}
53
Back
© 2025 bowen.ge All Rights Reserved.