Skip to content

Commit 9b1eddd

Browse files
authored
Create 198.py
1 parent 7c23ab6 commit 9b1eddd

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

101-500/198.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
class Solution(object):
3+
# @param num, a list of integer
4+
# @return an integer
5+
def rob(self, nums):
6+
"""
7+
:type nums: List[int]
8+
:rtype: int
9+
"""
10+
last, now = 0, 0
11+
for i in nums:
12+
last, now = now, max(last + i, now)
13+
return now

0 commit comments

Comments
 (0)