Largest Submatrix With Rearrangements | Build Intuition | 3 Approaches | Leetcode 1727
Vložit
- čas přidán 5. 07. 2024
- Whatsapp Community Link : www.whatsapp.com/channel/0029...
This is the 73rd Video of our Array Playlist.
In this video we will try to solve a very good 2D array problem - Largest Submatrix With Rearrangements (Leetcode -1727).
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.
Problem Name : Largest Submatrix With Rearrangements
Company Tags : Google, Directi
My solutions on Github(C++ & JAVA) : github.com/MAZHARMIK/Intervie...
Leetcode Link : leetcode.com/problems/largest...
My DP Concepts Playlist : • Roadmap for DP | How t...
My Graph Concepts Playlist : • Graph Concepts & Qns -...
My GitHub Repo for interview preparation : github.com/MAZHARMIK/Intervie...
Subscribe to my channel : / @codestorywithmik
Instagram : / codestorywithmik
Facebook : / 100090524295846
Twitter : / cswithmik
With Sorting Approach Summary :
The algorithm iterates through each row of the matrix and updates the values in the matrix based on the number of consecutive 1s above the current cell. After updating the matrix, it sorts each row in non-ascending order and calculates the area of the largest rectangle formed by consecutive 1s in each column. The maximum area encountered across all rows is stored in the variable result, which is then returned as the final output.
Without Sorting Approach Summary :
Here, the algorithm uses two vectors: prevHeights and heights. prevHeights stores pairs of heights and corresponding column indices from the previous row, while heights is updated for the current row based on the values in prevHeights and the current row of the matrix.
For each column in the current row, the code checks the height of consecutive 1s based on the information from the previous row. It updates the heights vector accordingly, keeping track of the heights and corresponding column indices.
╔═╦╗╔╦╗╔═╦═╦╦╦╦╗╔═╗
║╚╣║║║╚╣╚╣╔╣╔╣║╚╣═╣
╠╗║╚╝║║╠╗║╚╣║║║║║═╣
╚═╩══╩═╩═╩═╩╝╚╩═╩═╝
✨ Timelines✨
0:00 - Introduction
2:54 - Intuition Building + Thought Process
5:30 - Approach 1 - Story To Code + Code + Complexity
30:22 - Approach 2 - Story Explanation + Code + Complexity
36:40 - Approach 3 - Story Explanation + Code + Complexity
#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
Best Explanation so far in youtube :)
I was worried if people would watch a lengthy video. I am so glad you watched it.
Thank you 😇🙏❤️
You Are Streak Saver❤ #MIK
Hey, it means a lot to me 😇🙏❤️
Thank you so much for watching 🙏🙏❤️❤️
A small tip for everyone, you can pin this snippet on your clipboard and paste it before submitting. More often than not, it beats 90%+ TC and sometimes even passes testcases upto 2*1e8 :
#include
#include
#include
#pragma GCC optimize("O3")
static auto _ = [](){
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
return nullptr;
}();
Also as a follow up to this question, you can try Largest Rectangle in Histogram on LC
thanks :)
wow! thanks
Can u explain HOW?
My first ever 2d matrix question of medium level that I did the coding all by myself after understanding the intuition. Great explanation idk how to even say how good the explanation was even tho it was a lengthy video
I watched 2-3 videos on youtube since morning. And this is by far the most detailed and perfect explanation found till now.
Man, you are fantastic. Just loved the build-up of the solution. Incredible.
I had no clue how to approach the problem. But after watching up to 16th minute of your video the solution become crystal clear. I paused it there and implemented the solution. It got accepted. Now watching the rest of your approaches. 💌
great share
Thank sir for daily motivation
Day : 10 streak continues 😃
This was an appropriate problem for a Sunday. I was not able to come up even with the first approach and when I realised it was solvable without sorting, I was blown away. I mean how can someone explain such complex solutions so perfectly! Hats off!!
You are a life saver and my leetcode streak saver.
You are literally the best explainer for any Qn (be it hard, east, medium). I learn things from this channel everyday.
3rd Approach was so damn on point. Loved the problem entirely.
Thank you so much!! Great explanation as always.
sir you should also upload contest problem as well
pleasee
What an explanation man!!
In the first loop to calculate consecutive ones even if we started from 1 row, it wil not matter and that way we dont have to check for the out of bound. nice explanation.
Thank you so much for your efforts
Was waiting for video from the morning
It was really a good question
very well explained thank you
Thanks a lot 👍
best explanation in youtube
sir please post the contest solutions and thank you sir for posting quality free content like this
Who came from LinkedIn just to see he bhi ya nhi bande ka yt channel but ii to famous nikla :)
😁😇❤️🙏🙏
Was waiting for your video bhaiya.
Hope you enjoyed it! 😇🙏❤️
Asked in Google and Directi
Thank You❤❤
Thank you so much sir 🙏😊
Tags - Directi , Google
Wow. Thanks a lot for sharing ❤️🙏
@@codestorywithMIK no problem bhai🫂
i think hardest question of this week
Waited❤❤❤
Means a lot
Hope the video explanation is detailed and helpful 🙏❤️
thank you to do video in hindi
thank you brother
Thank you 😇🙏❤️
thank so much dude for explaining this question which makes me confuse too much .
Can you tell me how to solve 363.Max Sum of Rectangle No Larger Than K ?
Bhaiya contest ke questions ka bhi solution banaya kro 🙏🙏
Goat
matrix chain multiplication pls
Sir Approach 2 focused on not altering the original matrix, or it is reducing time complexity ?
Approach -2 is mainly for not manipulating input array.
op++++++;
and huffman coding
pleasee share your solution here bro
Hey! Anyone wants to make a WebD project with me..I don't have a partner who is little bit profecient in backend because I am well good in frontend
please make the videos short its too long. try not to exceed 15 mins
no sir keep it the same way as it is now
if you want short videos go to other channel which has incomplete concept been told of a question