Furthest Building You Can Reach | What is Lazy Greedy | Recursion | Memoization | Leetcode 1642

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



Duration: 51:23
5,125 views
328


iPad PDF Notes - https://github.com/MAZHARMIK/Interview_DS_Algo/blob/master/iPad%20PDF%20Notes/Leetcode-1642-Furthest%20Building%20You%20Can%20Reach.pdf
Whatsapp Community Link : https://www.whatsapp.com/channel/0029Va6kVSjICVfiVdsHgi1A
This is the 28th Video of our Playlist "Greedy : Popular Interview Problems".
We will try to understand the thought process behind solving such Qns.

Problem Name : Least Number of Unique Integers after K Removals | Leetcode 642
Company Tags : Microsoft, Google
My solutions on Github :
Heap - (Lazy Greedy) - https://github.com/MAZHARMIK/Interview_DS_Algo/blob/master/Heap/Furthest%20Building%20You%20Can%20Reach.cpp
Recursion + Memo - https://github.com/MAZHARMIK/Interview_DS_Algo/blob/master/DP/Furthest%20Building%20You%20Can%20Reach.cpp
Leetcode Link : https://leetcode.com/problems/furthest-building-you-can-reach/


Approach Summary :
Approach-1 (Recur + Memo) - Explore both options. Try with bricks and try with ladder and find the max you reach from both. Return the furthest you can go.

Approach-2 (Lazy Greedy) - The person has the option to use either bricks or ladders to overcome the height difference between adjacent buildings. The solution iterates through the buildings, and for each pair of consecutive buildings, it calculates the height difference (diff). If the difference can be covered using available bricks, the bricks are used, and the difference is added to a priority queue. If bricks are insufficient, it checks if using a ladder would be a better choice by comparing with the maximum difference covered using bricks in the past. If a ladder is used, it decrements the available ladders. The process continues until either the person runs out of buildings or resources. The function returns the index of the last building reached. The priority queue helps keep track of the maximum bricks used, allowing for potential recovery if a ladder becomes available later.


My Recursion Concepts Playlist : https://www.youtube.com/watch?v=pfb1Zduesi8&list=PLpIkg8OmuX-IBcXsfITH5ql0Lqci1MYPM
My DP Concepts Playlist : https://youtu.be/7eLMOE1jnls
My Graph Concepts Playlist : https://youtu.be/5JGiZnr6B5w
My GitHub Repo for interview preparation : https://github.com/MAZHARMIK/Interview_DS_Algo
Subscribe to my channel : https://www.youtube.com/@codestorywithMIK
Instagram : https://www.instagram.com/codestorywithmik/
Facebook : https://www.facebook.com/people/codestorywithmik/100090524295846/
Twitter : https://twitter.com/CSwithMIK

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

Timelines : ⏰
00:00 - Problem Explanation
6:49 - Why Greedy Fails ?
11:47 - Recursion + Memoization - Tree Diagram
21:18 - Coding Recursion + Memoization
26:41 - Lazy Greedy ??? Intuition
37:54 - Story To Code
45:15 - Coding Lazy Greedy


#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 #2024 #newyear




Other Videos By codestorywithMIK


2024-02-25Generate Parentheses | 2 Approaches | Magic Of Recursion | Recursion Concepts And Questions
2024-02-25Greatest Common Divisor Traversal | Why Graph | Why DSU | Google | Leetcode 2709
2024-02-24Find All People With Secret | 4 Approaches | Google | Leetcode 2092
2024-02-23Thank you and Love You All ❤️🙏
2024-02-23N-Queens | 2 Approaches | Super Detailed | Magic Of Recursion | Recursion Concepts And Questions
2024-02-21Bitwise AND of Numbers Range | 2 Approaches | Dry Run | Leetcode 201
2024-02-19Missing Number | Multiple Approaches | Leetcode 268
2024-02-19Flattening a Linked List | Magic Of Recursion | Recursion Concepts And Questions | Video 13
2024-02-18Power of Two | Multiple Approaches | Leetcode 231
2024-02-18Meeting Rooms III | Detailed Intuition | Brute Force | Optimal | Leetcode 2402
2024-02-16Furthest Building You Can Reach | What is Lazy Greedy | Recursion | Memoization | Leetcode 1642
2024-02-16Flatten BST to sorted list | Magic Of Recursion | Recursion Concepts And Questions | Video 12
2024-02-16Least Number of Unique Integers after K Removals | 3 Approaches | Greedy | Leetcode 1481
2024-02-15Rat in a Maze Problem | Simple Story To Code | Recursion Concepts And Questions | Video 11
2024-02-14Find Polygon With the Largest Perimeter | Thought Process | Greedy | Leetcode 2971
2024-02-14Subsets | Simple Story To Code | Leetcode 78 | Recursion Concepts And Questions | Video 10
2024-02-13Rearrange Array Elements by Sign | 2 Approaches | Why Order Preserve | Leetcode 2149
2024-02-13Quick Sort | Simple Story | Story To Code | Recursion Concepts And Questions | Video 9
2024-02-12Find First Palindromic String in the Array | Multiple Ways | Leetcode 2108
2024-02-11Cherry Pickup II | 3 Approaches | Super Detailed | Leetcode 1463
2024-02-10Tumlog saath ho. Bas kaafi hai ❤️ 18K family #codestorywithmik