4 Steps to Solve Any Dynamic Programming (DP) Problem

preview_player
Показать описание
FAANG Coding Interviews / Data Structures and Algorithms / Leetcode
Рекомендации по теме
Комментарии
Автор

Master Data Structures & Algorithms For FREE at AlgoMap.io!

GregHogg
Автор

4th step sometimes not possible, but yeah up to 3 definitely.

rohitkumaram
Автор

very good summary of the step by step optimisation of DP problems, but it is hard for new learner to understand these 4 steps without a full blown explanation.

sonicjoy
Автор

Great video demonstrating progressive code refinement. Still not sure if the first step should be called "recursive backtracking". As discussed in previous video, think this is just "naïve recursion".

azursmile
Автор

What's complicated about DP IMO is figuring out what do the output depend on in such a way that it's memoizable, when facing new and complicated problems, It's not obvious at all

yassinesafraoui
Автор

I find that top-down solutions are easier to understand due to the decision tree nature of the solution as opposed to the bottom-up with dp that is sometimes harder to find the transition step.

Xrist
Автор

I think the memo dict would be a new one for each stack frame. I might be wrong. You are better off using lru_cache from functools or make the dict global

abiiranathan
Автор

I thought I was good with Python until I saw this video

kakimell
Автор

I feel like you just summed up one the first lecture on dynamic programming from an old mitocw series

balasujithpotineni
Автор

I can usually think of a top down approach but not the bottom up

sarthakjain
Автор

Hey Gregg, I'd love to see a deep dive into DP. Most importantly, I'd like to know how I can convert my naive approach progress from top-down to bottom-up to true dp solutions.
Thanks in advance.

tomislam
Автор

5th solution, solve it on O(ClogN) where C depends on the dp specific recursion

carlgauss
Автор

I dint understand 2nd one but other 3 were still understanable

nihalbhamrah
Автор

How to do the 4th step in antoher algorithm? For example the knapsack?

foerza
Автор

If we want to go little further we can take a look at the Golden ratio

armandomendivil
Автор

i dont know about the caching thing thanks for telling and explaining

carlkarl
Автор

#4 should be optimized space complexity which includes O(1) for 1D DP instead of O(n) and O(n) for 2D DP instead of O(n^2)

abdallaalhag
Автор

Just for folks. 4th is not greedy approach. It’s still a dp based.

HeatCode
Автор

To solve dp you should solve dp 3 times.
..got it

Allthenameable
Автор

me* watches how to solve dynamic programming problems

also me* messes up f-strings

hepotitus