Complete Dynamic Programming Practice - Noob to Expert | Topic Stream 1

Ғылым және технология

Problemset link: codeforces.com/contestInvitat...
Harmonic series blog: discuss.codechef.com/t/more-i...
I end up covering problems A-H and K in the problemset.
Here's part 2, where I finish it: • Complete Dynamic Progr...
Note that problem explanations are probably long because of interacting with chat, not necessarily because of difficulty. Also, sometimes I refer to the problemset as a "mashup" because Codeforces calls it that.
Timestamps:
Intro 00:00
Intro to DP (Fibonacci) 04:19
Mashup A 21:20
Mashup B 45:37
Trying to pin a message 52:05
Continuing B 56:25
Mashup C 1:08:49
Mashup D 1:30:45
Mashup E 1:46:22
Intermission (+ water bottle inspiration) 2:12:05
Mashup F 2:17:45
Figuring out what a derangement is 2:48:59
Mashup G 3:00:24
Mashup H 3:28:14
Mashup K 3:39:26

Пікірлер: 173

  • @ColinGalen
    @ColinGalen Жыл бұрын

    Seems like this video is hitting the algorithm. For those of you who are new here - I have a face now, and also a significantly better mic :)

  • @dipankarkumarsingh

    @dipankarkumarsingh

    Жыл бұрын

    😊 Good to See you back on KZread [ after a long break ] .... And yes this video is really Quality content [ with Lots of Varity on Questions ] thanks for the video

  • @austinwitherspoon4940

    @austinwitherspoon4940

    Жыл бұрын

    .lm . . .. . . .... . .. . .. . . ... . . .. . . . . . . . . . ..... .... .. ........ . . .. . . . . .. . . . .. . . . ... . . .. .....

  • @austinwitherspoon4940

    @austinwitherspoon4940

    Жыл бұрын

    O ... ..... . . . . . ... ..... .... .. ... . . . . . . ... .... ..... .. .. .. . . . . .. .. .. .. mm.. ... ...... ...... . . .. .. .. . ... . . M................ . . ..... .. .. ..... . ......... .... .... . . .. ....... . ... . ....... ... . . ... ................. ..

  • @Gukslaven

    @Gukslaven

    Жыл бұрын

    Honestly the best tutorial I've seen for DP. I'm working through the problems and referring back to this vid as I get stuck, making progress :)

  • @minfoodtravels

    @minfoodtravels

    Жыл бұрын

    programming becoming more widely available and newbies like myself find your methods of teaching very easily absorbing into my brain cells, I thank you for your great and entertaining content and deep knowledge on DP.

  • @abhinavghosh725
    @abhinavghosh7253 жыл бұрын

    for me the hardest part of DP is finding out that this is a Dp problem . btw you repeatedly said rows in place of column and vice versa many times , other than that it was perfect !

  • @shreyghugtiyal4118

    @shreyghugtiyal4118

    2 жыл бұрын

    exactly😂

  • @Shreyas535

    @Shreyas535

    Жыл бұрын

    For me the hardest part is to identify a greedy problem. I have the least success rate in identifying greedy problems.

  • @therealg9542

    @therealg9542

    4 ай бұрын

    If the problem can be solved by solving subproblems, the problem is most likely a dp question. If the solution to the current subproblem cannot be solved using previous subproblems, then the question is most likely not a dp question. dp intuition requires practice.

  • @sayantansinharay9161
    @sayantansinharay91613 жыл бұрын

    I am 19 :) still watching you learn something. One suggestion my friend please don't get distracted by live comments

  • @Code_Note

    @Code_Note

    3 жыл бұрын

    lol didnt expect u here

  • @sayantansinharay9161

    @sayantansinharay9161

    3 жыл бұрын

    @@Code_Note brooooo my school kanishk i too do cp a bit bro connect up you on linkedin or discord

  • @Code_Note

    @Code_Note

    3 жыл бұрын

    @@sayantansinharay9161 ok

  • @Cpp_For_Life

    @Cpp_For_Life

    5 ай бұрын

    I am 19 too 😢

  • @victorleroux-avantin-sq1rv

    @victorleroux-avantin-sq1rv

    Ай бұрын

    🎉❤​@@Code_Note😂❤😂

  • @timothygao9442
    @timothygao94423 жыл бұрын

    "Improving is a random thing"

  • @ColinGalen

    @ColinGalen

    3 жыл бұрын

    There are probably a lot of good quotes in this video lol

  • @harshadaggarwal6029

    @harshadaggarwal6029

    3 жыл бұрын

    @@ColinGalen my favorite at 2:10:20

  • @alonsocerpa2745

    @alonsocerpa2745

    2 жыл бұрын

    @@harshadaggarwal6029 hahaha

  • @jakeambrose4294
    @jakeambrose4294 Жыл бұрын

    Wow this seems like what ive been dying to find. I sure hope it is. I appreciate all your effort and sharing the knowledge my friend!

  • @watchlistsclips3196
    @watchlistsclips31963 жыл бұрын

    I am soo glad that you are making a video on graphs .It will be lot more helpful to many people if you make videos on problems involving greedy method like u made for topics such as trees, dynamic programming . Like where we need to use this approach. We have very less videos regarding this.

  • @stemwithsagnik7096
    @stemwithsagnik7096 Жыл бұрын

    Thank you so much for this series!

  • @professionalFriend
    @professionalFriend3 жыл бұрын

    Good Work...First i can try questions on my own and see your video if i get stuck at some problem.

  • @DonTequilon
    @DonTequilon Жыл бұрын

    what an incredible video, hope you the best.

  • @koocheukkeijacky9704
    @koocheukkeijacky97043 жыл бұрын

    Thank you so much! I learnt a lot in all of your tutorial stream

  • @dejavukun
    @dejavukun3 жыл бұрын

    Thanks a lot for the contest. Please avoid getting distracted by the comments. Breaks the flow of explanation.

  • @kinershah464
    @kinershah464 Жыл бұрын

    Great video. I tried my best to follow and understand the concepts. Just one suggestion, if you can use better variable names to represent DP states. Using variable names like i, j and k can be confusing sometimes. I know you are used to using shorter names since it's way convenient and fast for CP but I will really appreciate if you could use slightly longer and meaningful names, of course only during explanation for better understanding and avoiding any confusion. Again thanks for great explanation. Really appreciate the time you have taken to explain the DP concepts.

  • @vanchark
    @vanchark Жыл бұрын

    I appreciate you putting out this free educational content, but a suggestion would be to try to stay focused while explaining your thought process. It's hard to follow along when mid-thought you reply to chat :(

  • @lakshyabamne
    @lakshyabamne8 ай бұрын

    my right ear enjoyed this stream very much, cant say the same for my left year though :)

  • @sunshodan5883
    @sunshodan58833 жыл бұрын

    please keep making topic streams

  • @dangduong5362
    @dangduong53622 жыл бұрын

    thanks for your helpful lecture

  • @harshsrivastava5124
    @harshsrivastava51243 жыл бұрын

    Thanks a lot it really helped.. Hoping to see more of these streams :)

  • @abhaypatil2000
    @abhaypatil20003 жыл бұрын

    Definitely you are getting to 10k.cause once a person start watching you he is going to stick with you

  • @sazidimtiaz831
    @sazidimtiaz8313 жыл бұрын

    thank you very much!❣️

  • @eshumanohare7614
    @eshumanohare7614 Жыл бұрын

    A non-dp solution to problem G #include #include using namespace std; typedef long long ll; int main(){ ll v1, v2; cin >> v1 >> v2; ll t, d; cin >> t >> d; ll ans = v1 + v2; for(ll i=1; i

  • @igorbeliyaveski7600
    @igorbeliyaveski760011 ай бұрын

    Thank you!!!

  • @vishnusingh4118
    @vishnusingh41183 жыл бұрын

    Thanks for these vids man! One suggestion - The audio quality is a dampener to the amazing efforts you're putting in. If it's a short video, it's bearable, but in long streams like these, audio is actually way more important than video. If you could invest a bit in a better mic, it would do a world of good to up the quality of audio. Thanks again for your efforts and value addition to the community. Learning a ton from you!

  • @ColinGalen

    @ColinGalen

    3 жыл бұрын

    Yep, this is an older video, and I have a much better mic for some of the newer ones.

  • @nathann6518

    @nathann6518

    3 жыл бұрын

    @@ColinGalen I need help, for mashup A, I do get 2*f(n-2), do to probability, but I don’t get f(n-2) + f(n-2) and how you got that solution using DP

  • @lingcheng2971
    @lingcheng29712 жыл бұрын

    For problem F, your original code is almost passing. if (k>=4) ans += 3 * nck(n,4) + nck(n,2)*nck(n-2,2); can pass all tests.

  • @karasensei2308
    @karasensei2308 Жыл бұрын

    not know , but just know you've affected my life, and apparently tens of thousands of others, in an imnsely positive way. Thank you

  • @trillionman2105
    @trillionman2105 Жыл бұрын

    Probably the first two problems would be better in a tutorial on when you should avoid dp solutions even if they are possible.

  • @shreyashachoudhary480
    @shreyashachoudhary4802 жыл бұрын

    Thanks!

  • @mangalegends
    @mangalegends Жыл бұрын

    So I just realized something after see you do Mashup B. One of the big parts of my struggle with DP questions is understanding what the heck the question is really asking. I saw the solution to the number of typeable substrings for the example string "abacaba" is 12, and I could not see how there are 12 substrings. I could only count 5: a ab aba ba b I couldn't fathom how there's 12 until like the next day I took a look again and it occurred to me that they're counting the same character multiple times if it's in the string in different places. So they're not looking for the count of unique substrings, which was pretty counterintuitive for me

  • @anhuynh1172
    @anhuynh11724 ай бұрын

    You help me a lot

  • @Aysh_Sach_16-2
    @Aysh_Sach_16-23 жыл бұрын

    will you conduct more such? highly needed bruh!

  • @ColinGalen

    @ColinGalen

    3 жыл бұрын

    Yeah, I do plan more in the future, there's just not much time for me to do them currently.

  • @user-cr6gp5qf2m
    @user-cr6gp5qf2m4 ай бұрын

    Hey @ColinGalen I did not understood why are you using min() in mashup C's ?

  • @nasimnajand9697
    @nasimnajand96978 күн бұрын

    Great!

  • @user-ii5wn2nr2b
    @user-ii5wn2nr2b6 ай бұрын

    Just checking this out

  • @Spectrum_Aerospacejet_Lab
    @Spectrum_Aerospacejet_Lab8 ай бұрын

    Robots and Relays.

  • @user-io4sr7vg1v
    @user-io4sr7vg1v5 ай бұрын

    FFT is not DP. It uses the decimation algorithm because so many of the elements end up being zeros. It can be 'memoized' but to break it up into smaller subproblems doesn't give any benefit.

  • @pranjalpriyadarshi1289
    @pranjalpriyadarshi12893 жыл бұрын

    How do I get the list of all the codeforces mashups which you have created!

  • @dheerajbhagchandani7529
    @dheerajbhagchandani75293 жыл бұрын

    yeah it's good for me

  • @sarathkumarnallendhiran2815
    @sarathkumarnallendhiran2815 Жыл бұрын

    Please do a topic stream on recursion and backtracking.

  • @AKRahim-wg5dm
    @AKRahim-wg5dm3 жыл бұрын

    golden voice

  • @nallasivakrishnasai1122
    @nallasivakrishnasai11223 жыл бұрын

    @Colin Galen In problem E(office keys) Can you please help me in formally proving that the greedy way of having continuous assignment between the keys and people is optimum. Anyone's help would be really useful.

  • @dakshchhabra5975

    @dakshchhabra5975

    2 жыл бұрын

    Lets say P1 and P2 are positions of two people and k1 and k2 are positions of two Keys I am going to explain one of the case when k1>P1 and k2 > P2, other 3 cases you can deduce by yourself Distance if we assign P1 to k2 and P2 to k1 is K2-P1 + (p2-k1) if we assume P2> k1 Surely this dis is greater than K1-p1 + (p2-k2) because P2>k1 Other cases you can prove similarly

  • @samarjyoti-ray
    @samarjyoti-ray3 жыл бұрын

    5:41 "No Way!" t'was funny 😂😂 You must be working with Python, I guess?

  • @bobapplebob9695
    @bobapplebob969511 ай бұрын

    I incredibly doubt you will see this due to the fact that you apparently have a ton of subscribers all of a sudden, but thought you'd get a kick out of me having found this video through autoplay while asleep, you can imagine my surprise when I woke up and I heard a voice I recognized.

  • @laraibanwar1618
    @laraibanwar16183 жыл бұрын

    Hey colin can u plz teach line sweep algorithms with example plz.. Ur videos are awesome tho. Great work and i like the ways u teach. Best 👍

  • @abhinavrajhans1107
    @abhinavrajhans11073 жыл бұрын

    i do not understand the dth question in that we can keep him awake for k straight minutes and if we choose start of 3 then we can keep him awake till [3,3+3-1] which includes 5 2 5 so the sum is 12 but how sum is coming as 14 please help ?

  • @dontony7071
    @dontony70713 жыл бұрын

    Next one on graphs and trees🤔

  • @LadderVictims
    @LadderVictims4 күн бұрын

    1:03:00 didnt understand the logic as to why f(i)= f(i-1)+1, if f(i) is the no of substrings ending with index i

  • @Poignant_
    @Poignant_11 ай бұрын

    Hello, in the past couple of days my internet started acting very strange, my lights are a solid green and a blinking orange but whenever i try to play an online game i keep getting disconnected but the little icon in the right corner still says in connected, how can i fix this?

  • @akashbhoi1951
    @akashbhoi1951 Жыл бұрын

    Is this the extension or something else (the box with the right arrow) :)

  • @brandonstark4133
    @brandonstark41333 жыл бұрын

    Why can't I join the MashUp GYMS(PROBLEMSETS)?

  • @M4rt1nX
    @M4rt1nX11 ай бұрын

    Yeah, the algo got me here. It was on autoplay while I was sleeping.

  • @prateekchauhan9044
    @prateekchauhan90443 жыл бұрын

    Please explain codechef november long questions

  • @prasaddash5139
    @prasaddash51393 жыл бұрын

    i am still not able to get the C problem can any one suggest a place to read it again

  • @haricharanpal1761
    @haricharanpal17613 жыл бұрын

    Can u make a video on how do use templates

  • @abhaypatil2000
    @abhaypatil20003 жыл бұрын

    I am not comfortable using push dp. Is it ok to use recursive dp. I mean are there any questions which can be done by push dp and not with recursive dp?

  • @ColinGalen

    @ColinGalen

    3 жыл бұрын

    Yes, there are some. However, they usually involve difficult recurrences, and won't show up until the higher end of the difficulty scale. In almost all cases, it's completely fine to use recursive DP, and whatever you use is preference. By the time you get to the point of having to solve the harder ones, you'll probably be comfortable enough with DP to be able to do it.

  • @Phoenix-xi2gy
    @Phoenix-xi2gy3 жыл бұрын

    Can you please provide some resource or some intuition for "taking continuous keys will give us optimal solution" part of E problem Office Keys

  • @parthpawar7837
    @parthpawar78373 жыл бұрын

    In problem A, f(n) = 2f(n-2) because we choose a 2x3 block (which has 2 orientations) and multiply with the solution of f(n-2), hence 2f(n-2). But we can also chose that 2x3 block in n ways, so why isn't the relation f(n) = n*2*f(n-2) ?

  • @ColinGalen

    @ColinGalen

    3 жыл бұрын

    Because the location of the block is irrelevant - if you put it somewhere in the middle, it'll be equivalent to putting it in the middle later (i.e. the order in which you place down blocks is irrelevant). So that recurrence will drastically overcount. I use the recurrence I do to make the subproblems independent - if I place it at the (right) end of the current grid, then it will be completely independent from the rest of the grid, and thus not overcount.

  • @parthpawar7837

    @parthpawar7837

    3 жыл бұрын

    @@ColinGalen Makes sense. Thanks for clearing this

  • @shubhamk840
    @shubhamk8403 жыл бұрын

    Since you have crossed more than 5k subs, you should now switch to something like electronic writing pad I guess.

  • @ColinGalen

    @ColinGalen

    3 жыл бұрын

    soon™

  • @cpwithsundar

    @cpwithsundar

    3 жыл бұрын

    what is he using in this video to write

  • @derilraju2106

    @derilraju2106

    Жыл бұрын

    @@cpwithsundar ms paint

  • @nimanthadilz
    @nimanthadilz2 жыл бұрын

    Hi Colin, In problem E-Office Keys, I understand why you say two people can't cross their paths to get the keys. But you didn't say why you choose key positions continuously. I mean if first person is assigned to ith key position, second person is assigned to (i+1)th position and so on. What is the reason for this ?

  • @theblinkingbrownie4654

    @theblinkingbrownie4654

    Жыл бұрын

    The second person is not assigned to the (i+1)th position, he has the CHOICE to choose the (i+1)th position and any key after that

  • @Axjira
    @Axjira3 ай бұрын

    I woke up to this. How does someone end here starting from brawl stars kmak

  • @AlgorithmAlchemy69
    @AlgorithmAlchemy699 ай бұрын

    F can be easily be solved using dearrangements!

  • @josephwong2832
    @josephwong28322 жыл бұрын

    awesome stream colin

  • @SonicCGames
    @SonicCGames11 ай бұрын

    oh loawd im coming

  • @vinicus508
    @vinicus5087 ай бұрын

    I slept with KZread on and this video started playing. I dreamt about a guy who was solving the Navier Stokes millennium equation using some sort of toy that he moves around with his fingers (that was you typing). Lmao

  • @ramhemanth1132
    @ramhemanth1132 Жыл бұрын

    Can you share the code for each problem please.

  • @pulkitjoshi28
    @pulkitjoshi282 жыл бұрын

    Hey, in problem A, shouldn't f[0] be 0, since a 3x0 grid doesn't make sense.

  • @jakeambrose4294
    @jakeambrose4294 Жыл бұрын

    theres very very very little amount of resources on the internet that help people from 0-100 with constructive resources and telling them what to drill and practice.

  • @docstyagi7775
    @docstyagi77753 жыл бұрын

    In problem E, office keys. Taking a contiguous segment of keys is always optimal. Can this lead to a better complexity than O(people * keys).

  • @shivarajpatil8699
    @shivarajpatil8699 Жыл бұрын

    Do you actually Questions like this or do it in the mind?

  • @MSISAmar
    @MSISAmar3 жыл бұрын

    Pls make more videos🙏

  • @alphaco3868
    @alphaco38682 жыл бұрын

    It took 1 month to complete dp where some people trying to learn dp in one day ..... :D

  • @anunaysharma5609
    @anunaysharma56093 жыл бұрын

    Hey Colin, can you please make a video for beginners on how to become red on codeforces, thank you

  • @udoigogoi6828
    @udoigogoi68283 жыл бұрын

    Galen colin in cp:🔥🔥🔥🔥🔥🔥

  • @rightspotadvertising1786
    @rightspotadvertising1786 Жыл бұрын

    Woow woow

  • @nguyenhoangdung3823
    @nguyenhoangdung38233 жыл бұрын

    what? Discord LIGHT THEME ???

  • @Artaxerxes.

    @Artaxerxes.

    3 жыл бұрын

    ikr its blinding

  • @newman6492
    @newman6492 Жыл бұрын

    I think you don't know what is row and what is column?

  • @adcaptandumvulgus4252
    @adcaptandumvulgus42522 ай бұрын

    As soon as I heard the word math I went "nope"

  • @eliotcamel7799
    @eliotcamel779911 ай бұрын

    First few problems be like: "Imagine doing the O(1) solution when there's an O(n) solution"

  • @yashkumarsingh9713
    @yashkumarsingh97135 ай бұрын

    do one for recursion

  • @vinhnghiang1273
    @vinhnghiang1273 Жыл бұрын

    what is this IDE?

  • @revanthkalavala1829
    @revanthkalavala1829 Жыл бұрын

    Problem F should be more suitable in Math category rather than DP.

  • @huhuboss8274
    @huhuboss8274 Жыл бұрын

    Only 30k left until he can pin comments

  • @vedbhatawadekar6842
    @vedbhatawadekar68423 жыл бұрын

    can someone explain what is the time complexity of solution in K?

  • @Eurotool
    @Eurotool6 ай бұрын

    Dreamed of this annoying know-it-all from my previous job He was "teaching" me things I already knew He said "now I'm gonna teach you recursion" And I replied I ALREADY KNOW WHAT THAT IS And he flat out ignored me Then he said "okay to learn recursion we're gonna use fibonacci's sequence. but first let's learn what fibonacci's sequence is" I was like NO I KNOW WHAT IT IS but again he ignored me Eventually I was fed up so I left the room But he CALLED ME and kept explaining fibonacci's sequence Then I woke up and found out KZread was playing this random programming tutorial

  • @pinyichang4680
    @pinyichang4680 Жыл бұрын

    dynamic

  • @xagiziga
    @xagiziga11 ай бұрын

    wew

  • @itz_me_imraan02
    @itz_me_imraan022 жыл бұрын

    Couldn't understand some problems clearly....you could have explained some problems in more details....don't recommend this for beginners 😔..

  • @pleasesirmorevideos4684
    @pleasesirmorevideos46843 жыл бұрын

    Nice Stream just avoid reading chats so much, they distract a lot rest all are fine

  • @imranif3899

    @imranif3899

    3 жыл бұрын

    Why? It's his channel, he has the complete freedom to do streams the way he deems it fun as well as informative. It's no easy task doing a 4hr streaming without taking much of a break.

  • @pleasesirmorevideos4684

    @pleasesirmorevideos4684

    3 жыл бұрын

    @@imranif3899 you are so cute

  • @imranif3899

    @imranif3899

    3 жыл бұрын

    @@pleasesirmorevideos4684 lol...couldn't you just avoid reading my comment? So distracting, wasn't it? I highly doubt your ability to do what you just said.

  • @pleasesirmorevideos4684

    @pleasesirmorevideos4684

    3 жыл бұрын

    @@imranif3899 you are still so cute

  • @ColinGalen

    @ColinGalen

    3 жыл бұрын

    @@pleasesirmorevideos4684 Bruh, even if you know each other, don't be toxic

  • @user-cr6gp5qf2m
    @user-cr6gp5qf2m4 ай бұрын

    1:57:11

  • @user-xb8jc9bq3b
    @user-xb8jc9bq3bАй бұрын

    @ColingGalen, do you drink coffee?

  • @Monty.digital
    @Monty.digital22 күн бұрын

    math people are smart as fuck

  • @mamtachahal1277
    @mamtachahal12773 жыл бұрын

    BTW how old are you?

  • @ColinGalen

    @ColinGalen

    3 жыл бұрын

    17

  • @iitnakanpur..

    @iitnakanpur..

    3 жыл бұрын

    @@ColinGalen 😲😲😲😲

  • @Aysh_Sach_16-2

    @Aysh_Sach_16-2

    3 жыл бұрын

    @@ColinGalen seriously??

  • @hacksource1784
    @hacksource1784 Жыл бұрын

    GLAD I MET HACKERS SUMMIT WHO SORTED MY GRADES ISSUES,THEY CAN HELP YOU

  • @miriotogata8993
    @miriotogata89938 ай бұрын

    28:00

  • @AHMEDSAAD-od3bg
    @AHMEDSAAD-od3bg2 жыл бұрын

    Did'nt you go to ioi??

  • @Keitan97
    @Keitan9711 ай бұрын

    I set KZread on auto play when I was asleep… where the fuck am I?

  • @t.r.venkat7661
    @t.r.venkat76612 жыл бұрын

    ur too much into live chat!!...this turns irritating at a point

  • @DoPlayGameYes
    @DoPlayGameYes6 ай бұрын

    yeah i can really tell you are 17 right now. i couldn't sit for 10 seconds of this

  • @a.htonmoy1896
    @a.htonmoy18962 жыл бұрын

    Why this people in the chat talk more about other shits than the problems in a topic stream ! It's irritating 😑

  • @extraFart
    @extraFart Жыл бұрын

    2:02:34 onichan

  • @vimmiduggal6658
    @vimmiduggal6658 Жыл бұрын

    1:23:58 For personal use, please ignore

  • @WalkingHeadPro
    @WalkingHeadPro11 ай бұрын

    booooorrrrinnnnggg

Келесі