Back to course home

0% completed

# House thief

There are `n`

houses built in a line. A thief wants to steal the maximum possible money from these houses. The only restriction the thief has is that he can't steal from two consecutive houses, as that would alert the security system. How should the thief maximize his stealing?

## Problem Statement

Given a number array representing the wealth of `n`

houses, determine the maximum amount of money the thief can steal without alerting the security system.

**Example 1:**

```
Input: {2, 5, 1, 3, 6, 2, 4}
Output: 15
Explanation: The thief should steal from houses 5 + 6 + 4
```

**Example 2:**
``

.....

.....

.....

Like the course? Get enrolled and start learning!