The problem. Like House Robber, but the houses stand in a circle: the first and the last house are neighbours too. Return the most you can rob without robbing two adjacent houses.
nums = [2, 3, 2] -> 3
nums = [1, 2, 3, 1] -> 4
nums = [1, 2, 3] -> 3Members only · free account
The rest of this lesson, with 6 more sections, 1 drawing, a dry-run simulator and code in JavaScript, Python, Java and C++, opens with a free account.
Not ready yet? The Arrays course is free to read, no account needed.
In the rest of this lesson