We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bbc01b5 commit 1c506bbCopy full SHA for 1c506bb
415.add_string/solution.rs
@@ -0,0 +1,41 @@
1
+impl Solution
2
+{
3
+ pub fn add_strings(mut num1: String,mut num2: String) -> String
4
+ {
5
+ let mut temp = String::new();
6
+ let mut v:u8 = 0;
7
+ loop
8
9
+ let v1 = num1.pop();
10
+ let v2 = num2.pop();
11
+ if v1 == None && v2 == None && v ==0
12
13
+ break;
14
+ }
15
+ if let Some(v1) = v1
16
17
+ v += v1 as u8 - 48;
18
19
+ if let Some(v2) = v2
20
21
+ v+= v2 as u8 - 48;
22
23
+ let v3:u8 = v%10;
24
+ temp.push_str(&(v3.to_string()));
25
+ v /= 10;
26
27
+ let mut rst = String::new();
28
29
30
+ if let Some(ch) = temp.pop()
31
32
+ rst.push(ch);
33
34
+ else
35
36
37
38
39
+ return rst;
40
41
+}
0 commit comments