House Robber II Problem

House Robber II Problem — ExecCode Medium DSA Practice

Solve the House Robber II problem on ExecCode. Free online medium DSA practice in Arrays - Basics. Write and run code in Java, C++, Python — no signup required to run.

Problem description

Houses are arranged in a circle, so the first and last houses are adjacent. Each house has a loot value. Return the maximum amount you can rob without robbing two adjacent houses.

Examples

Input nums = [1, 2, 3, 1]; Output 4. Input nums = [2, 3, 2]; Output 3. Input nums = [1, 2, 3]; Output 3

Constraints

1 ≤ nums.length ≤ 100 0 ≤ nums[i] ≤ 1000

Practice House Robber II free on ExecCode. Browse DSA problems, topic map, and placement guides.