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 58ce3be commit 41ca9beCopy full SHA for 41ca9be
house-robber/daiyongg-kim.py
@@ -0,0 +1,16 @@
1
+class Solution:
2
+ def rob(self, nums: List[int]) -> int:
3
+ rob_prev_prev = 0
4
+ rob_prev = 0
5
+ max_today = 0
6
+ for rob_current in nums:
7
+ contains_rob_current = rob_current + rob_prev_prev
8
+ not_contains_rob_current = rob_prev
9
+
10
+ max_today = max(contains_rob_current, not_contains_rob_current)
11
12
+ rob_prev_prev = rob_prev
13
+ rob_prev = max_today
14
15
+ return max_today
16
0 commit comments