(Old) Leetcode 198 - House Robber | Dynamic Programming

preview_player
Показать описание
Topic: Dynamic Programming

Code:

Leetcode:

*Note* I claim no rights to this question. All rights belong to Leetcode. If I'm reviewing a solution that was from another Leetcode user or Leetcode itself I will give credit below.

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

Thanks for the explanation, its great and very easy to understand. But I think this would work only if the robber can skip one house at max. It wouldn't work for [2, 1, 1, 2] if the robber can skip more than 1 house. In that case, we have to look back at all previous entries in the dp array and add that to nums[i].

sushwanthn
Автор

frankly speaking, I didn't understand how you reached to your recurrence formula at all. It felt that you just shouted the answer right away. I don't understand why does this solution works for four houses, I can't undertand the thinking process that brought you to the conclusion in 1:32

ganqqwerty
visit shbcf.ru