House Robber
Learn House Robber (Dynamic Programming, Advanced DSA) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.
Maximize Loot Without Robbing Two Adjacent Houses At each house, choose: SKIP it (carry forward the best result without it), or ROB it (its value plus the best result from two houses back, since the adjacent one can't also be robbed). dp[i] = max(dp[i-1], dp[i-2] + nums[i]) .
More lessons in Dynamic Programming
- Fibonacci (DP)
- Climbing Stairs
- Kadane (DP)
- Grid Paths
- Unique Paths
- Minimum Path Sum
- 0/1 Knapsack
- Unbounded Knapsack
- Bounded Knapsack
- Subset Sum
- Equal Partition
- Target Sum
- Longest Common Subsequence - LCS
- Longest Common Substring
- Edit Distance
- Longest Palindromic Subsequence
- Palindrome Partitioning
- Longest Increasing Subsequence - LIS
- Number of LIS
- Maximum Sum Increasing Subsequence
- Matrix Chain Multiplication
- Burst Balloons
- Optimal BST
- Diameter (Tree DP)
- Maximum Path Sum (Tree DP)
- Tree Independent Set
- Traveling Salesman Problem
- Assignment Problems
- Counting Numbers (Digit DP)
- Digit Constraints