← problems
#213

House Robber II

MediumDynamic Programming

Same as House Robber, but the houses are arranged in a circle, so the first and last houses are adjacent. Return the maximum amount you can rob without robbing two adjacent houses.

Example

nums = [2, 3, 2]     => 3   // can't rob houses 0 and 2 (adjacent)
nums = [1, 2, 3, 1]  => 4
Implement
function Rob2(nums: int[]) -> int

Found a bug? Or annoyed about something in the language? Tell us.

loading editor…