Notice Period

Quiet Burglar

medium

A burglar works a street of houses, each holding loot[i] in cash. The houses share a wired alarm: hitting two adjacent houses on the same night trips it.

Return the maximum cash the burglar can collect in one night without ever robbing two neighbors.

Example 1
in loot = [1, 2, 3, 1]
out 4
Rob houses 0 and 2: 1 + 3 = 4.
Example 2
in loot = [2, 7, 9, 3, 1]
out 12
Rob houses 0, 2, 4: 2 + 9 + 1 = 12.
Constraints
  • · 1 <= len(loot) <= 1000
  • · 0 <= loot[i] <= 10^4
similar problem on LeetCode ↗
solution.pyloading python…
test results
Hit ▶ Run to test your code against the visible cases.