LeetCode 198. House Robber [Algorithm + Code Explained ]

preview_player
Показать описание
One of the most frequently asked coding interview questions on Arrays in companies like Google, Facebook, Amazon, LinkedIn, Microsoft, Uber, Apple, Adobe etc.

LeetCode : House Robber

Question : You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent houses have security system connected and it will automatically contact the police if two adjacent houses were broken into on the same night.

Given a list of non-negative integers representing the amount of money of each house, determine the maximum amount of money you can rob tonight without alerting the police.

Example 1:

Input: [1,2,3,1]
Output: 4
Explanation: Rob house 1 (money = 1) and then rob house 3 (money = 3).
Total amount you can rob = 1 + 3 = 4.
Example 2:

Input: [2,7,9,3,1]
Output: 12
Explanation: Rob house 1 (money = 2), rob house 3 (money = 9) and rob house 5 (money = 1).
Total amount you can rob = 2 + 9 + 1 = 12.

Рекомендации по теме
Комментарии
Автор

Thanks for explaining the solution in such a simple way. Thanks for taking out time and making such useful videos.

ShabnamKhan-cjzc
Автор

great explanation mam, thnk you so much!

santasingh
Автор

Hi jayati, could you please share the link of Solving Methods PPT . It would be extremely beneficial to me.

DeepakGupta-crsr
Автор

One request. Whenever you explain a dynamic programming problem, please start off with the less optimised solution and explain why that wouldn't work and then take us through the dynamic programming solution. That would help people understand the importance of dynamic programming.

sohamsen
Автор

good video! Please also tell memoization solution.

callmechocolateboy
Автор

Where I can find this presentation with solving methods? It looks really cool.

pancernymisiek
Автор

Nhi smjh aa rha mujhe try to speak in hindi india walo ko hi sikha lo.

badshah
welcome to shbcf.ru