Opening your workspace…
Workspace/Coding room
Opening your workspace…
Jason has spent twelve dollars trying to beat the House Robber machine at a Vice City arcade. Lucia puts in a quarter. The high score is eighty bucks. How did he spend twelve real dollars trying to steal eighty pretend ones?
The screen shows a street of houses, with a dollar amount over each front door. Tap a house to collect its money. The houses immediately to its left and right then lock for the rest of the game. Given the amounts in street order, return the most money Lucia can collect. She can leave any house alone. An empty street pays zero.
[2,7,9,3,1]Output12Choose the first, third and fifth houses for 2 + 9 + 1.
[4,5]Output5Only one of the two doors can be tapped.
Compare skipping this door with collecting it after the best result two doors back.
function solve(amounts) { // Write your solution here. }
Tab inserts two spaces. Shift+Tab outdents. Use the arrow keys and Tab to choose a suggestion. Press Escape, then Tab, to leave the editor. Press Control or Command with apostrophe to run samples or with Enter to submit.