Night Thief (Arrays & Lists)

A thief walks down a street of houses, each holding some gold. Taking gold from two neighbouring houses sets off the alarm. Print the most gold the thief can take.

Input: n (1 to 100), then n amounts from 0 to 400.

Output: One integer.

Difficulty: Medium. Write your answer in the browser editor, run the examples, then submit it against hidden tests. Python and JavaScript are free; other languages are part of licode Club.

Hint

  • For each house: skip it (keep the best so far) or rob it (best from two houses back + this one).

More Arrays & Lists practice