House Robber II
Problem Houses in a CIRCLE each hold money; adjacent houses can't both be robbed, and house 0 and house n−1 are adjacent. Maximize the take.
Input / Output
- Input: int array nums. Output: max sum.
Constraints
- n up to 100 classically; O(n) time, O(1) space expected.
Example
- [2,3,2] → 3 (can't take both 2s — they're circular neighbours); [1,2,3,1] → 4.
asked …