Skip to content

Commit e1d219d

Browse files
committed
house robber solution
1 parent 4b46c37 commit e1d219d

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

house-robber/6kitty.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#
2+
# @lc app=leetcode id=198 lang=python3
3+
#
4+
# [198] House Robber
5+
#
6+
7+
# @lc code=start
8+
class Solution:
9+
def rob(self, nums: List[int]) -> int:
10+
pre=0
11+
cur=0
12+
for num in nums:
13+
pre, cur = cur, max(num + pre, cur)
14+
return cur
15+
16+
# @lc code=end
17+

0 commit comments

Comments
 (0)