House Robber II
Rob houses arranged in a circle by solving the straight-street problem twice: once without the first house and once without the last.
The problem
Implement Solution.rob(nums). nums[i] is the money in house i, and the houses stand in a circle, so the first and the last house are next to each other. You may never rob two neighbouring houses. Return the largest total you can rob. There are between 1 and 100 houses, and each holds between 0 and 1,000.
Starter code
class Solution:
def rob(self, nums):
passPublic examples
nums = [2, 3, 2]gives3nums = [2, 7]gives7nums = [1, 2, 1, 6]gives8
Solving it in the practice book needs an active paid plan.
Open it in the practice bookOne thought at a time.
