Skip to content

Commit 8909bba

Browse files
authored
Create Solution3.java
1 parent 6a24c58 commit 8909bba

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class Solution {
2+
public int rob(int[] nums) {
3+
int f = 0, g = 0;
4+
for (int x : nums) {
5+
int ff = Math.max(f, g);
6+
g = f + x;
7+
f = ff;
8+
}
9+
return Math.max(f, g);
10+
}
11+
}

0 commit comments

Comments
 (0)