Solve the House Robber II (circular arrangement) problem
Problem Houses are arranged in a circle, each holding a non-negative amount of money. Adjacent houses share a connected security system, so robbing two adjacent houses triggers an alarm. Because the arrangement is circular, the first and last houses are also adjacent. Return the maximum amount you can rob without alerting the police.
Input / Output
- Input: integer array
nums, the money in each house (in circular order). - Output: the maximum total robbable with no two adjacent houses (including first/last) both taken.
Constraints
- 0 ≤ nums.length; values are non-negative.
- The first and last elements are adjacent.
Example
- nums = [2,3,2] → 3 (can't take houses 0 and 2 together).
- nums = [1,2,3,1] → 4 (houses 0 and 2).
asked …