House Robber Problem

House Robber Problem — ExecCode Medium DSA Practice

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

Problem description

You are a robber planning to rob houses along a street. Each house has a certain amount of money. Adjacent houses have security systems — you cannot rob two adjacent houses. Maximize loot.

Examples

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

Constraints

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

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