```
def rob(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
n = len(nums)
if n == 0:
return 0
if n == 1:
return nums[0]
pre1 = nums[0]
pre2 = 0
for i in range(1,n):
pre1, pre2 = max(pre1, pre2+nums[i]), pre1
return pre1
```