House Robber II
Houses are arranged in a circle, each holding some money in nums. You cannot rob two adjacent houses, and because the arrangement is circular the first and last houses are adjacent. Return the maximum amount you can rob without alerting the police.
Open official problem prompt ↗Maximize looted money on a circular street where no two chosen houses may be neighbors, including the wrap-around pair.
Choosing non-adjacent seats around a round table: picking both seats next to the same gap is forbidden, so you plan the row twice - once ignoring the first seat, once ignoring the last.
- Input
- nums = [2, 3, 2]
- Output
- 3
- Why
- Robbing house 0 and house 2 is illegal (they are adjacent on the circle), so the best single choice is house 1 with 3.
1 <= nums.length <= 1000 <= nums[i] <= 1000