Standard solution, I guess, except I take a shortcut for the one-house case.
class Solution: def rob(self, nums): def rob(nums): now = prev = 0 for n in nums: now, prev = max(now, prev + n), now return now return max(rob(nums[len(nums) != 1:]), rob(nums[:-1]))
Can you explain what this is? (Why this works)
nums[len(nums) != 1:]
I've never seen an expression like this: list[boolean:]
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.