Filling Bookcase Shelves | Recursion Memoization | Why not Greedy | Leetcode 1105 | codestorywithMIK

Subscribers:
92,300
Published on ● Video Link: https://www.youtube.com/watch?v=pOtAvGIW8kQ



Duration: 29:49
11,465 views
538


Whatsapp Community Link : https://www.whatsapp.com/channel/0029...
This is the 97th Video of our Playlist "Dynamic Programming : Popular Interview Problems" by codestorywithMIK

In this video we will try to solve a very good DP based problem : Filling Bookcase Shelves | Recursion Memoization | Why not Greedy | Leetcode 1105 | codestorywithMIK

I will explain the intuition so easily that you will never forget and start seeing this as cakewalk EASYYY.
We will do live coding after explanation and see if we are able to pass all the test cases.
Also, please note that my Github solution link below contains both C++ as well as JAVA code.

Problem Name : Minimum Deletions to Make String Balanced | Multiple Approaches | Dry Run | Leetcode 1653 | codestorywithMIK
Company Tags : will update soon
My solutions on Github(C++ & JAVA) : https://github.com/MAZHARMIK/Intervie...
Leetcode Link : https://leetcode.com/problems/filling...


My DP Concepts Playlist :    • Roadmap for DP | How to Start DP ? | ...  
My Graph Concepts Playlist :    • Graph Concepts & Qns - 1 : Graph will...  
My Recursion Concepts Playlist :    • Introduction | Recursion Concepts And...  
My GitHub Repo for interview preparation : https://github.com/MAZHARMIK/Intervie...
Instagram :   / codestorywithmik  
Facebook :   / 100090524295846  
Twitter :   / cswithmik  
Subscribe to my channel :    / @codestorywithmik  

╔═╦╗╔╦╗╔═╦═╦╦╦╦╗╔═╗
║╚╣║║║╚╣╚╣╔╣╔╣║╚╣═╣
╠╗║╚╝║║╠╗║╚╣║║║║║═╣
╚═╩══╩═╩═╩═╩╝╚╩═╩═╝

Summary :
The approach to solving the problem of placing books on shelves with the minimum height is based on dynamic programming and recursion. Here's a breakdown of the approach:

Dynamic Programming Setup:

A memoization table t is used to store intermediate results to avoid redundant calculations. The table is indexed by the current book index and the remaining width on the current shelf.
Recursive Function solve:

The function solve is defined to determine the minimum height for placing books from the current index onward, given the remaining width on the current shelf and the maximum height of the current shelf.
Base Case: If all books have been processed , return the maximum height of the current shelf (maxHt).
Memoization Check: If the result for the current state (i, remainW) is already computed, return it from the table.
Options: For each book, there are two main options:
Keep the book on the current shelf: If the book fits, recursively calculate the height for the remaining books.
Skip to the next shelf: Place the book on a new shelf and recursively calculate the height for the remaining books.
The result for the current state is the minimum of the two options, which is stored in the memoization table.
Initialization and Execution:

The main function minHeightShelves initializes the class variables and the memoization table, then starts the recursive process with all books unplaced and the full shelf width available.

✨ Timelines✨
00:00 - Introduction

#coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge #leetcodequestions #leetcodechallenge #hindi #india #coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge#leetcodequestions #leetcodechallenge #hindi #india #hindiexplanation #hindiexplained #easyexplaination #interview#interviewtips #interviewpreparation #interview_ds_algo #hinglish #github #design #data #google #video #instagram #facebook #leetcode #computerscience #leetcodesolutions #leetcodequestionandanswers #code #learning #dsalgo #dsa #newyear2024




Other Videos By codestorywithMIK


2024-08-09Minimum Number of Days to Disconnect Island | Studied Concept | Leetcode 1568 | codestorywithMIK
2024-08-09Regions Cut By Slashes | Already Studied Concept | Easy Code | Leetcode 959 | codestorywithMIK
2024-08-08Magic Squares In Grid | Simple Approach | Clean Code | Leetcode 840 | codestorywithMIK
2024-08-08Thank you 60,000 Subscribers ❤️
2024-08-06Spiral Matrix III | Simple Simulation | Made Easy | Leetcode 885 | codestorywithMIK
2024-08-05Integer to English Words | Story To Code | Leetcode 273 | codestorywithMIK
2024-08-03Happy Friendship Day ❤️
2024-08-03Range Sum of Sorted Subarray Sums | Learning Something New | Leetcode 1508 | codestorywithMIK
2024-08-01Make Two Arrays Equal by Reversing Subarrays | Easy | Leetcode 1460 | codestorywithMIK
2024-07-31Minimum Swaps to Group All 1's Together II | 2 Ways | Dry Runs | Leetcode 2134 | codestorywithMIK
2024-07-29Filling Bookcase Shelves | Recursion Memoization | Why not Greedy | Leetcode 1105 | codestorywithMIK
2024-07-28Minimum Deletions to Make String Balanced | Multiple Approaches | Leetcode 1653 | codestorywithMIK
2024-07-27Count Number of Teams | Simple thought process | Intuition | Leetcode 1395
2024-07-26Second Minimum Time to Reach Destination | 2 Approaches | FULL DRY RUN | Leetcode 2045
2024-07-24Find the City With the Smallest Number of Neighbors at a Threshold Distance | 3 Ways | Leetcode 1334
2024-07-22Sort the Jumbled Numbers | 2 Approaches | Leetcode 2191 | codestorywithMIK
2024-07-20Minimum Operations to Make Array Equal to Target | Minimum Number of Increments|Leetcode 3229 & 1526
2024-07-19Build a Matrix With Conditions | BFS | DFS | Detailed Explanation | Leetcode 2392 | codestorywithMIK
2024-07-19Palindrome Partitioning | Using Blue Print | DP On Strings | Leetcode 131 | DP Concepts & Qns-27
2024-07-18Find Valid Matrix Given Row and Column Sums | Simple Approach | Leetcode 1605 | codestorywithMIK
2024-07-18Number of Good Leaf Nodes Pairs | Simple DFS | Dry Run | Leetcode 1530 | codestorywithMIK