You're a master thief planning the heist of a lifetime! This time, you've targeted a circular street where houses form a complete loop - meaning the first house is right next to the last house.
Each house contains a different amount of cash, represented by the array nums. However, there's a catch: the houses have a connected security system that will trigger an alarm if you rob any two adjacent houses on the same night.
Since the street is circular, you face an additional constraint: you cannot rob both the first AND last house, as they are neighbors!
Goal: Return the maximum amount of money you can steal without triggering the security system.
Example: Given houses [2,3,2] in a circle, you can rob house 2 (middle) for 3 total, but you cannot rob houses 1 and 3 together since house 1 and 3 are adjacent in the circle.
Input & Output
Visualization
Time & Space Complexity
We generate 2^n subsets and check each one
Recursion stack depth and subset storage
Constraints
- 1 โค nums.length โค 100
- 0 โค nums[i] โค 1000
- All houses are arranged in a circle