class Solution:
# @param num, a list of integer
# @return an integer
def rob(self, num):
left = left_left = 0
for i in xrange(len(num)):
left, left_left = max(num[i] + left_left, left), left
return left
A simple Python slution

DP, similar to bearstand's solution
def rob(self, nums): if len(nums) <= 0: return 0 elif len(nums) == 1: return nums[0] elif len(nums) == 2: return max(nums[0],nums[1]) else : arr = [0]*len(nums) arr[0] = nums[0] arr[1] = max(nums[0],nums[1]) for i in range(2,len(nums)) : arr[i] = max(arr[i2] + nums[i], arr[i1]) return arr[len(nums)1]