your way of telling the intuition to think problem solution helps a lot ..like here you told whenever we have to do multiple task on same element it might be related to dp ...tnks sir !
@@priyanshgarg1292 yes, in dp we generally store all the states that our program is going to visit. So if it is 1D array O(N), 2d array then N*M, and so on..
Is memoization called DP? I had this before coming here- but looks like we ended up at the same O(n^2) solution ``` from typing import List class Solution: def minHeightShelves(self, books: List[List[int]], shelfWidth: int) -> int: memo = {} def solveRecursive(i, current_shelf_width, current_shelf_height, total_height_so_far): if i >= len(books): return total_height_so_far + current_shelf_height key = (i, current_shelf_width, current_shelf_height, total_height_so_far) if key in memo: return memo[key] min_height = float('inf') if current_shelf_width + books[i][0]
👦 :- Hopefully, it will work.. and it did.. now, let's try to submit it ❤😇🥰
Masterpiece line❤
bhaiya...pls ek dp ka series chahiye....hope u will hear...!!
Keep doing good work!!
Bhaiya, you deserve a million subscribers please wait your content is very good be continue
Thanks 😊
your way of telling the intuition to think problem solution helps a lot ..like here you told whenever we have to do multiple task on same element it might be related to dp ...tnks sir !
Thanks from the bottom of my heart ❤❤
nice explanation
great explanation
means in case of using dp our tc becomes 2d dp size?
@@priyanshgarg1292 yes, in dp we generally store all the states that our program is going to visit. So if it is 1D array O(N), 2d array then N*M, and so on..
@@shashwat_tiwari_st🙏
This is a memoization solution, try adding tabulation solution as well.
Is memoization called DP?
I had this before coming here- but looks like we ended up at the same O(n^2) solution
```
from typing import List
class Solution:
def minHeightShelves(self, books: List[List[int]], shelfWidth: int) -> int:
memo = {}
def solveRecursive(i, current_shelf_width, current_shelf_height, total_height_so_far):
if i >= len(books):
return total_height_so_far + current_shelf_height
key = (i, current_shelf_width, current_shelf_height, total_height_so_far)
if key in memo:
return memo[key]
min_height = float('inf')
if current_shelf_width + books[i][0]
@@ShivangiSingh-wc3gk memorization is one of the type of dp or a means to achieve dp
Bhaiya I am not able to figure out the code for tabulation. Can you please upload the same ??
😍😍
why we didn't take height as a perameter in this question at the time of creating the dp Array
Nahi samjh aaya sir
Plz provide solutions link always
Bhaiya mera name bhi shashwta hai ❤