Problem
A robber plans to take money from houses that stand in a circle. The integer array nums gives the amount of money in each house, in order around the circle.
The robber cannot take money from two adjacent houses. Because the houses form a circle, the first house and the last house are adjacent.
Return the maximum total amount of money that the robber can take.
Example 1
- Input:
- nums = [4,2,5]
- Output:
- 5
- Explanation:
- In a circle of three houses, each pair of houses is adjacent. So the robber takes money from one house only, and 5 is the largest amount.
Example 2
- Input:
- nums = [7,1,1,7]
- Output:
- 8
- Explanation:
- The two houses with 7 are adjacent in the circle. The best total is
7 + 1, which is 8.
Example 3
- Input:
- nums = [2,6,3,8,1]
- Output:
- 14
- Explanation:
- Take money from the houses at indexes 1 and 3. The total is
6 + 8, which is 14.
Constraints
- 1 <= nums.length <= 100
- 0 <= nums[i] <= 1000
SysRound wrote this statement. A reference solution checks every example.
Related questions
Continue with questions that share topics or the same question type.
- House Robber
Coding · Array · Dynamic Programming
- House Robber III
Coding
- House Robber IV
Coding
- Number of Ways to Build House of Cards
Coding
Sources · 1 reference
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 3 records
Amazon
Leetcode 213. House Robber II
Reported Jan 16, 2026 · 2 source reports
MID_LEVEL, SENIOR
Source snapshot: Nov 12, 2026
View sourceDigitalocean
Leetcode 213. House Robber II
Reported Aug 23, 2026 · 1 source report
SENIOR
Source snapshot: Nov 12, 2026
View sourceMicrosoft
Leetcode 213. House Robber II
Reported Jan 5, 2026 · 1 source report
SENIOR
Source snapshot: Nov 12, 2026
View source