super cool implementation at the end, editorial suggests KMP/Trie and ofc Robin Karp is one of these solutions too (although not in editorial). Python actually has that if statement down to O(n) vs. O(m + n) or O(n^2) that other languages support
but i don't know any of these so will def look into KMP since it seems to be super common. also, did watch the first lecture of the DP, planning to do the rest throught this week.. while still not entirely sure how to implement, I like the breakdown by the prof
Thank you Bogus!! And ahhhh I see, I wonder how Python implements it under-the-hood then 🧐 KMP I’d have to learn how to build the z-tables which I remember isn’t all that difficult, though Robin-Karp was definitely much more intuitive for me :) Abdul Bari has videos on both of these which I watched myself and are really great, I’ve even left the Robin-Karp one as a link in the description in case you’re curious 😊 Ayyyyyyyy I’m glad to hear you started watching that lecture!! Reason I like that lecture is from how Erik breaks down DP in the most naive way possible: brute force, but with caching in case of repeated work. If we were in school together and had a white board I could probably make you understand it within 5 minutes by just visualizing an example of what’s going on with the same Fibonacci example and just drawing down the tree 😂 But really DP is as simple as that: Brute Force solution, but keep track of a hash map that maps an input to its output whenever you compute a solution, and then of course at start of function returning early if you’ve already solved the problem before :) If you can internalize it that way, then see how it’s done for say some of the 1D DP Neetcode 150 problems with memoization (not bottom up), it will eventually click 😁 I hope you’ve been well my friend, thanks again for always taking the time to chat with me in the comments :)
super cool implementation at the end, editorial suggests KMP/Trie and ofc Robin Karp is one of these solutions too (although not in editorial). Python actually has that if statement down to O(n) vs. O(m + n) or O(n^2) that other languages support
but i don't know any of these so will def look into KMP since it seems to be super common. also, did watch the first lecture of the DP, planning to do the rest throught this week.. while still not entirely sure how to implement, I like the breakdown by the prof
Thank you Bogus!! And ahhhh I see, I wonder how Python implements it under-the-hood then 🧐
KMP I’d have to learn how to build the z-tables which I remember isn’t all that difficult, though Robin-Karp was definitely much more intuitive for me :) Abdul Bari has videos on both of these which I watched myself and are really great, I’ve even left the Robin-Karp one as a link in the description in case you’re curious 😊
Ayyyyyyyy I’m glad to hear you started watching that lecture!! Reason I like that lecture is from how Erik breaks down DP in the most naive way possible: brute force, but with caching in case of repeated work. If we were in school together and had a white board I could probably make you understand it within 5 minutes by just visualizing an example of what’s going on with the same Fibonacci example and just drawing down the tree 😂 But really DP is as simple as that: Brute Force solution, but keep track of a hash map that maps an input to its output whenever you compute a solution, and then of course at start of function returning early if you’ve already solved the problem before :) If you can internalize it that way, then see how it’s done for say some of the 1D DP Neetcode 150 problems with memoization (not bottom up), it will eventually click 😁
I hope you’ve been well my friend, thanks again for always taking the time to chat with me in the comments :)