Skip to content

Commit 6a24c58

Browse files
authored
Create Solution3.go
1 parent 59d5f07 commit 6a24c58

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
func rob(nums []int) int {
2+
f, g := 0, 0
3+
for _, x := range nums {
4+
f, g = max(f, g), f+x
5+
}
6+
return max(f, g)
7+
}

0 commit comments

Comments
 (0)