Largest Submatrix With Rearrangements | Build Intuition | 3 Approaches | Leetcode 1727

Sdílet
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

Komentáře • 60

  • @deepjyotideka7816
    @deepjyotideka7816 Před 7 měsíci +16

    Best Explanation so far in youtube :)

    • @codestorywithMIK
      @codestorywithMIK  Před 7 měsíci +3

      I was worried if people would watch a lengthy video. I am so glad you watched it.
      Thank you 😇🙏❤️

  • @Kode_with_Kushwah
    @Kode_with_Kushwah Před 7 měsíci +8

    You Are Streak Saver❤ #MIK

    • @codestorywithMIK
      @codestorywithMIK  Před 7 měsíci +1

      Hey, it means a lot to me 😇🙏❤️
      Thank you so much for watching 🙏🙏❤️❤️

  • @vineetkumarmotwani474
    @vineetkumarmotwani474 Před 7 měsíci +6

    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;
    }();

  • @S3aw0lf
    @S3aw0lf Před 7 měsíci +2

    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

  • @ugcwithaddi
    @ugcwithaddi Před 7 měsíci +2

    I watched 2-3 videos on youtube since morning. And this is by far the most detailed and perfect explanation found till now.

  • @wearevacationuncoverers
    @wearevacationuncoverers Před 7 měsíci

    Man, you are fantastic. Just loved the build-up of the solution. Incredible.

  • @md.tamaltahasinkhan6448
    @md.tamaltahasinkhan6448 Před 7 měsíci +1

    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. 💌

  • @edocdrah
    @edocdrah Před 7 měsíci +1

    great share

  • @prateekgirilateralentry5865
    @prateekgirilateralentry5865 Před 7 měsíci +2

    Thank sir for daily motivation
    Day : 10 streak continues 😃

  • @sauravchandra10
    @sauravchandra10 Před 7 měsíci

    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!!

  • @Thriftinghai
    @Thriftinghai Před 7 měsíci +1

    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.

  • @souravjoshi2293
    @souravjoshi2293 Před 7 měsíci

    3rd Approach was so damn on point. Loved the problem entirely.

  • @Rits2203
    @Rits2203 Před 7 měsíci

    Thank you so much!! Great explanation as always.

  • @pratyushraghuvanshi1543
    @pratyushraghuvanshi1543 Před 7 měsíci +1

    sir you should also upload contest problem as well
    pleasee

  • @harshitjain8820
    @harshitjain8820 Před 7 měsíci +1

    What an explanation man!!

  • @2780_RashidMazhar
    @2780_RashidMazhar Před 7 měsíci +1

    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.

  • @sandeeprai1081
    @sandeeprai1081 Před 7 měsíci

    Thank you so much for your efforts

  • @de_coder1
    @de_coder1 Před 7 měsíci

    Was waiting for video from the morning
    It was really a good question

  • @aswithasai4015
    @aswithasai4015 Před 7 měsíci

    very well explained thank you

  • @tutuimam3381
    @tutuimam3381 Před 7 měsíci +1

    Thanks a lot 👍

  • @user-vd2jc7lm3h
    @user-vd2jc7lm3h Před 7 měsíci

    best explanation in youtube

  • @DeepakSingh-fd2ix
    @DeepakSingh-fd2ix Před 7 měsíci

    sir please post the contest solutions and thank you sir for posting quality free content like this

  • @letsboomit
    @letsboomit Před 7 měsíci +2

    Who came from LinkedIn just to see he bhi ya nhi bande ka yt channel but ii to famous nikla :)

  • @souravjoshi2293
    @souravjoshi2293 Před 7 měsíci +1

    Was waiting for your video bhaiya.

  • @de_coder1
    @de_coder1 Před 7 měsíci +1

    Asked in Google and Directi

  • @saurabhKumar-hj6yp
    @saurabhKumar-hj6yp Před 7 měsíci

    Thank You❤❤

  • @Akashkumar_12
    @Akashkumar_12 Před 7 měsíci

    Thank you so much sir 🙏😊

  • @ammanchhetri6716
    @ammanchhetri6716 Před 7 měsíci +5

    Tags - Directi , Google

  • @infinitygaming7192
    @infinitygaming7192 Před 7 měsíci +1

    i think hardest question of this week

  • @codeandtalk6
    @codeandtalk6 Před 7 měsíci +1

    Waited❤❤❤

    • @codestorywithMIK
      @codestorywithMIK  Před 7 měsíci +1

      Means a lot
      Hope the video explanation is detailed and helpful 🙏❤️

  • @Indian-s26
    @Indian-s26 Před 7 měsíci +1

    thank you to do video in hindi
    thank you brother

  • @aelishkumar1852
    @aelishkumar1852 Před 7 měsíci

    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 ?

  • @chillkro25
    @chillkro25 Před 7 měsíci

    Bhaiya contest ke questions ka bhi solution banaya kro 🙏🙏

  • @23cash86
    @23cash86 Před 7 měsíci

    Goat

  • @ultimatequora
    @ultimatequora Před 7 měsíci

    matrix chain multiplication pls

  • @DeepakSingh-fd2ix
    @DeepakSingh-fd2ix Před 7 měsíci +1

    Sir Approach 2 focused on not altering the original matrix, or it is reducing time complexity ?

    • @codestorywithMIK
      @codestorywithMIK  Před 7 měsíci

      Approach -2 is mainly for not manipulating input array.

  • @ss8273
    @ss8273 Před 7 měsíci

    op++++++;

  • @ultimatequora
    @ultimatequora Před 7 měsíci

    and huffman coding

  • @redamoney281
    @redamoney281 Před 7 měsíci

    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

  • @tdsd05
    @tdsd05 Před 7 měsíci

    please make the videos short its too long. try not to exceed 15 mins

    • @ultimatequora
      @ultimatequora Před 7 měsíci

      no sir keep it the same way as it is now

    • @ultimatequora
      @ultimatequora Před 7 měsíci

      if you want short videos go to other channel which has incomplete concept been told of a question