House Robber
Easy About 10 min Free, no account needed
Maximize the loot without robbing two adjacent houses.
The brief
Starter code
using System;
public class Solution
{
// TODO: return the maximum loot with no two adjacent houses robbed.
public long Rob(int[] nums)
{
throw new NotImplementedException();
}
}How it is graded
Visible examples help you iterate. Hidden tests then cover edge cases and larger inputs, and every test reports server-measured time and allocated bytes.
What it practices
- Dynamic programming
- Define subproblems and a recurrence, then reuse solved subproblems instead of recomputing them.
Related katas
- Climbing Stairs Easy Free Count the ways up a staircase taking one or two steps at a time.
- Counting Bits Easy Free Popcounts for 0..n - reuse the table you are already building.
- Min Cost Climbing Stairs Easy Free Pay each step you land on; reach the top as cheaply as possible.
- Unique Paths Easy Free Count the robot's lattice paths across the grid.