Skip to content

Commit 52b62a1

Browse files
authored
Create Solution3.rs
1 parent b1313e3 commit 52b62a1

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
impl Solution {
2+
pub fn rob(nums: Vec<i32>) -> i32 {
3+
let mut f = [0, 0];
4+
for x in nums {
5+
f = [f[0].max(f[1]), f[0] + x];
6+
}
7+
f[0].max(f[1])
8+
}
9+
}

0 commit comments

Comments
 (0)