Lucky Numbers in a Matrix | 2 Approaches | Dry Run | Leetcode 1380 | codestorywithMIK
Whatsapp Community Link : https://www.whatsapp.com/channel/0029...
This is the 49th Video of our Playlist "Leetcode Easy : Popular Interview Problems" by codestorywithMIK
In this video we will try to solve an easy Problem : Lucky Numbers in a Matrix | 2 Approaches | Dry Run | Leetcode 1380 | 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 : Lucky Numbers in a Matrix | 2 Approaches | Dry Run | Leetcode 1380 | codestorywithMIK
Company Tags : CISCO
My solutions on Github(C++ & JAVA) : https://github.com/MAZHARMIK/Intervie...
Leetcode Link : https://leetcode.com/problems/lucky-n...
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 :
Approach 1: Using Simple Traversal and Extra Space
Time Complexity (T.C): O(m*n)
Space Complexity (S.C): O(m+n)
Summary: This approach involves two main steps:
Finding Row Minimums: Traverse each row to find the minimum element in each row and store these minimums in a list (rowMin).
Finding Column Maximums: Traverse each column to find the maximum element in each column and store these maximums in a list (colMax).
Finally, it checks for each element in the matrix if it is both the minimum in its row and the maximum in its column. If so, it adds this element to the result list.
Approach 2: Finding the Lucky Number Greedily
Time Complexity (T.C): O(m*n)
Space Complexity (S.C): O(1)
Summary: This approach aims to find a single lucky number using a greedy strategy:
Finding Maximum of Row Minimums: Traverse each row to find the minimum element, and track the maximum of these row minimums (rMinMax).
Finding Minimum of Column Maximums: Traverse each column to find the maximum element, and track the minimum of these column maximums (cMaxMin).
If the maximum of the row minimums (rMinMax) is equal to the minimum of the column maximums (cMaxMin), this value is the lucky number and is returned as the result. If no such value exists, an empty list is returned.
✨ 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