Back to course home

0% completed

# House Robber II (medium)

## Problem Statement

You are given an array representing the amount of money each house has. This array models a circle of houses, meaning that the first and last houses are adjacent. You are tasked with figuring out the maximum amount of money you can rob without alerting the neighbors.

The rule is: if you rob one house, you cannot rob its adjacent houses.

### Example Generation

**Example 1:**

**Input:**[4, 2, 3, 1]**Expected Output:**7**Justification:**Rob the 1st and 3rd house, which gives 4 + 3 = 7.

**Example 2:**

**Input:**[5, 1, 2, 5]**Expected Output:**7

.....

.....

.....

Like the course? Get enrolled and start learning!