As reported: DigitalOcean SSE 2 onsite loop (DBaaS team), DSA round (2026): two LeetCode problems, this one and longest repeating character replacement.
Houses are arranged in a circle, so the first house is next to the last one. Each house holds some money, given as the array nums. Two adjacent houses cannot both be robbed on the same night. Return the maximum amount you can rob.
This is LeetCode 213 — House Robber II.
Example 1
nums = [2,3,2] -> 3 houses 0 and 2 are neighbors on the circle
Example 2
nums = [1,2,3,1] -> 4 rob houses 0 and 2
Example 3
nums = [1,2,3] -> 3
Constraints: 1 ≤ nums.length ≤ 100; 0 ≤ nums[i] ≤ 1000.
Code runner format: one line, nums as a JSON array. Implement rob(nums); the harness prints the amount.