Same as House Robber, but houses are arranged in a circle (first and last are adjacent). Return the maximum amount you can rob.
Example:
Input:
2,3,2
Output:
3
Reasoning:
The input represents the amount of money in each house, arranged in a circle: 2,3,2.
To find the maximum amount that can be robbed, we consider two cases: robbing the first house or not robbing the first house. If we rob the first house, we cannot rob the last house.
In this case, the maximum amount is obtained by robbing the house with 3,asrobbingthefirstandlasthouses(2 + 2=4) is not possible due to their adjacency.
The optimal solution is to rob the middle house, resulting in a maximum amount of $3.