@@ -12,14 +12,12 @@ impl Solution1 {
12
12
for ch in s. chars ( ) {
13
13
if ch. is_numeric ( ) {
14
14
curr_digit = curr_digit * 10 + ch. to_digit ( 10 ) . unwrap ( ) ;
15
- } else {
16
- if curr_digit != 0 {
17
- if prev >= curr_digit {
18
- return false ;
19
- }
20
- prev = curr_digit;
21
- curr_digit = 0 ;
15
+ } else if curr_digit != 0 {
16
+ if prev >= curr_digit {
17
+ return false ;
22
18
}
19
+ prev = curr_digit;
20
+ curr_digit = 0 ;
23
21
}
24
22
}
25
23
@@ -45,38 +43,38 @@ impl Bank {
45
43
46
44
fn transfer ( & mut self , account1 : i32 , account2 : i32 , money : i64 ) -> bool {
47
45
if !self . accounts . contains_key ( & account1) || !self . accounts . contains_key ( & account2) {
48
- return false ;
46
+ false
49
47
} else {
50
48
let avail = * self . accounts . get ( & account1) . unwrap_or ( & 0 ) ;
51
49
if avail >= money {
52
50
self . accounts . entry ( account1) . and_modify ( |b| * b -= money) ;
53
51
self . accounts . entry ( account2) . and_modify ( |b| * b += money) ;
54
- return true ;
52
+ true
55
53
} else {
56
- return false ;
54
+ false
57
55
}
58
56
}
59
57
}
60
58
61
59
fn deposit ( & mut self , account : i32 , money : i64 ) -> bool {
62
60
if !self . accounts . contains_key ( & account) {
63
- return false ;
61
+ false
64
62
} else {
65
63
self . accounts . entry ( account) . and_modify ( |b| * b += money) ;
66
- return true ;
64
+ true
67
65
}
68
66
}
69
67
70
68
fn withdraw ( & mut self , account : i32 , money : i64 ) -> bool {
71
69
if !self . accounts . contains_key ( & account) {
72
- return false ;
70
+ false
73
71
} else {
74
72
let avail = * self . accounts . get ( & account) . unwrap_or ( & 0 ) ;
75
73
if avail >= money {
76
74
self . accounts . entry ( account) . and_modify ( |b| * b -= money) ;
77
- return true ;
75
+ true
78
76
} else {
79
- return false ;
77
+ false
80
78
}
81
79
}
82
80
}
@@ -98,8 +96,8 @@ impl Solution3 {
98
96
if a == b | nums[ i as usize ] {
99
97
* count += 1
100
98
}
101
- subset ( & nums, count, i - 1 , a, b) ;
102
- subset ( & nums, count, i - 1 , a, b | nums[ i as usize ] ) ;
99
+ subset ( nums, count, i - 1 , a, b) ;
100
+ subset ( nums, count, i - 1 , a, b | nums[ i as usize ] ) ;
103
101
}
104
102
105
103
let mut count = 0 ;
0 commit comments