213. House Robber II

Practice House Robber II for free on NudgeCode: Medium, Dynamic Programming pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.

Same as House Robber, but the houses form a circle: the first and last house are neighbors too. You cannot take from two neighboring houses. Return the most money you can take.

Example

nums = [2,3,2]    ->  3   (houses 0 and 2 are neighbors)
nums = [1,2,3,1]  ->  4

Constraints