Houses are arranged in a circle. Adjacent houses cannot both be robbed. Return the maximum amount of money you can rob.
Example 1
Input: nums = [200,3,140,20,10]
Output: 340
Explanation: Rob houses 0 and 2 for 200 + 140 = 340. House 4 cannot be added because in a circle it is next to house 0.
Example 2
Input: nums = [2,3,2]
Output: 3
Explanation: In a circle, the first and last houses are neighbours, so you cannot rob both 2s. The best choice is the middle house, 3.
Example 3
Input: nums = [1,2,3,1]
Output: 4
Explanation: Rob houses 0 and 2 for 1 + 3 = 4. They are not adjacent, even in the circle.
Houses are arranged in a circle, so the very first and the very last houses are now adjacent — robbing both would set off the alarm. Split the circle into two linear cases: "rob without the last house" and "rob without the first house". The answer is the max of the two; each is a standard linear House Robber.
Run checks all cases above. Submit evaluates all test cases.