cheetcode

102. House Robber IIMedium

Maximize the money you can rob when the houses are arranged in a circle.

The houses are arranged in a circle, meaning the first and last houses are adjacent.

Return the maximum amount of money you can rob without taking two adjacent houses.

Examples

Input: nums = [2,3,2]
Output: 3
Input: nums = [1,2,3,1]
Output: 4

Constraints

  • 1 <= nums.length <= 100
  • 0 <= nums[i] <= 1,000