213. House Robber II (Medium) - TengnanYao/daily_leetcode GitHub Wiki
class Solution(object):
def rob(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
if len(nums) == 1:
return nums[0]
a = b = 0
for num in nums[:-1]:
a, b = b, max(num + a, b)
c = d = 0
for num in nums[1:]:
c, d = d, max(num + c, d)
return max(b, d)