Maximum Size Rectangle of All 1's Dynamic Programming

แชร์
ฝัง
  • เผยแพร่เมื่อ 15 ก.ย. 2024
  • Given a 2D matrix of 0s and 1s, find maximum size rectangle of all 1s in this matrix.
    github.com/mis...
    github.com/mis...

ความคิดเห็น • 150

  • @freethinker977
    @freethinker977 4 ปีที่แล้ว +11

    2020 - still the best explanation IMHO

    • @hitesh3859
      @hitesh3859 3 ปีที่แล้ว

      2021 - still the best explanation IMVHO

  • @2LegHumanist
    @2LegHumanist 6 ปีที่แล้ว +15

    Great explanation. I've been struggling with this one. All over the internet people just plonk their code down without explanation, but you explain it so simply.

    • @nikostrongioglou9941
      @nikostrongioglou9941 3 ปีที่แล้ว +4

      What exactly did he explain? He has an algorithm and he is walking through the algorithm... Nothing more than that. No word on HOW he came up with the algorithm or what is the intuition behind this...

    • @anushree3744
      @anushree3744 2 ปีที่แล้ว

      @@nikostrongioglou9941 exactly. Nothing on thought process.

  • @sait5489
    @sait5489 8 ปีที่แล้ว +24

    getting things very easily by listening to ur lectures... thank u :-)

  • @VladimirDjokic
    @VladimirDjokic 6 ปีที่แล้ว +10

    Great explanation! You should write a book "cracking the code interview"

    • @nguyenhoanvule5755
      @nguyenhoanvule5755 6 ปีที่แล้ว +6

      No bro! He should write the book "how to make the coding interview become a funny game". I feel really comfortable about his explain

  • @chandlerzhang9097
    @chandlerzhang9097 8 ปีที่แล้ว +1

    You can always explain complex algorithm in a simple way! love your video!

  • @ShabnamKhan-cj4zc
    @ShabnamKhan-cj4zc 4 ปีที่แล้ว

    U are always saviour for any tough question. Thanks for such simple explanation.

  • @kant.shashi
    @kant.shashi 7 ปีที่แล้ว +1

    Each row adds to values for histogram bars unless the cell value is 0 .. (i.e. bar is gone)
    and so at each row/level we check out maximum area under histogram (above the row)..which is the max rectangle.

  • @prakritiinusa
    @prakritiinusa 8 ปีที่แล้ว +14

    ya your explanations are simple , so easy to understand.. Thanks!!

    • @samarthsharma9019
      @samarthsharma9019 6 ปีที่แล้ว

      why are we using histogram ?

    • @contactdi8426
      @contactdi8426 3 ปีที่แล้ว

      @@samarthsharma9019 For that answer, you have to look at this problem: "Largest Rectangular area in Histogram"

  • @ShinAkuma
    @ShinAkuma 6 ปีที่แล้ว

    where were you all my life. Been struggling way too hard with this problem yet it's so simple.

  • @saifurrahmanbhuiyan925
    @saifurrahmanbhuiyan925 9 ปีที่แล้ว

    thnaks a lot tushar . i almost learnt all dp algorithm u provided. plz carry on ur great effort. and provide us more tutorial . I have learnt dynamic programmong from ur tutorial . i am indebted to you

  • @dibyendusarkar6821
    @dibyendusarkar6821 4 ปีที่แล้ว +1

    What I like about you, is you save a lot of time, thanks man

  • @ok123ut
    @ok123ut 4 ปีที่แล้ว +4

    an intuition to the approach would have been amazing. but great explanation!

  • @manivannanrajah
    @manivannanrajah 8 ปีที่แล้ว +54

    can we get an explanation on why this approach works?

    • @hardikraj9469
      @hardikraj9469 4 ปีที่แล้ว

      @@Bdjdiwhbkdk Thanks it really clear things up

  • @curious_haldar
    @curious_haldar 2 ปีที่แล้ว

    Beautifully explained

  • @anonymousmail9932
    @anonymousmail9932 2 ปีที่แล้ว +1

    Really best explanation

  • @robertkasper9890
    @robertkasper9890 4 ปีที่แล้ว +3

    How would you modify this algorithm to return all the coordinates of the largest rectangle, or a specific corner & the width and height?

    • @adhishmalviya2408
      @adhishmalviya2408 4 ปีที่แล้ว

      we need 3 things to get co-ordinates length breadth and lower left vertex: i think now you can find it anyways Im not going to type all of that

  • @enjili6062
    @enjili6062 3 ปีที่แล้ว

    Only a trivial personal thought for why the "histogram" strategy works: a rectangle must have its bottom width land on a row. Here, we are simulating through all the rows for to get the bottom width to make the rectangle the maximum.

  • @deepanshugupta5299
    @deepanshugupta5299 4 ปีที่แล้ว +1

    Every time I see his videos, I feel like its raining in the background

  • @nguyenkien5558
    @nguyenkien5558 3 ปีที่แล้ว

    Thanks for short and clear explanation!

  • @CryingMG
    @CryingMG 9 ปีที่แล้ว

    Lovely tutorials, Thanks alot Tushar!
    Learning so much from you!

  • @seank9122
    @seank9122 7 ปีที่แล้ว

    so fast yet so clear. great explanation!

  • @vaibhavchhabra800
    @vaibhavchhabra800 8 ปีที่แล้ว +1

    +Tushar Roy
    At time @5:44 u said that the Maximum Size Rectangle containing 1's is that (located at bottom down). How did u find that that is the box containing max 1's .Obv by luking at box v know that since max size is 8 and this box size is also 8 ,v can say that yes this box is the one , but how will a computer do it ?
    V know that the max size is 8, how to find the position of that box ?

  • @gyrogojo
    @gyrogojo 6 ปีที่แล้ว +6

    is this dynamic programming solution? We are not using solution to subproblems to get the final solution.

    • @xxbighotshotxx
      @xxbighotshotxx 5 ปีที่แล้ว +1

      Great question. Yes, we are. In order to solve for the input that we are given, we need to build the solution up row by row

    • @imalive404
      @imalive404 5 ปีที่แล้ว

      @Exodus .. The histogram is formed taking into account the previous rows. The height of any bar in the histogram is dependent on the previous row . If you look closely if (i, j) == 0 then our histogram height there is 0. But if (i,j)==1 then histogram height is height(i-1, j) + 1.
      Formally
      Say, h(i, j) = height of histogram bar at i, j
      then
      if (i, j) == 1:
      ....h(i, j) = h(i-1, j) + 1
      else:
      ...h(i, j) = 0
      Hope this helps

  • @SaitejaPamulapatipandu
    @SaitejaPamulapatipandu 8 ปีที่แล้ว +6

    I think it can be solved in O(1) space complexity , if you use 1st row or 1st column instead of extra array . Since you have no further use of it

    • @wozhendeaa
      @wozhendeaa 7 ปีที่แล้ว +6

      I think that what you are proposing will still be 0(n), where n is the width of the original array.

    • @karthikk5895
      @karthikk5895 6 ปีที่แล้ว

      Agree with Billy Yang.
      Also, finding the largest histogram function itself might take a space of O(col/rows).

  • @RaviMaurya-qi5ht
    @RaviMaurya-qi5ht 5 ปีที่แล้ว

    Why can't I like these videos more than once!!

    • @YashM1234
      @YashM1234 5 ปีที่แล้ว +2

      This is part of product design of 'TH-cam'.
      Feel free to contact youtube devs

  • @SatyanarayanaBolenedi
    @SatyanarayanaBolenedi 8 ปีที่แล้ว

    You Nicely build upon algorithm which u alrdy taught us!! Thanks Tushar!!

  • @9351379627
    @9351379627 8 ปีที่แล้ว +4

    Hi Tushar,
    You explain every problem very well, but I dont understand why this histogram logic works here. Please explain..Thanks

    • @sanyamsinghal7992
      @sanyamsinghal7992 4 ปีที่แล้ว +1

      for a rectangle we need two things, length and breadth, as the width is maintained by the array by summing up, then we just have to the appropriate length for given possible width so that we can decide our rectangle.
      So, with the help of histogram area here we are just deciding the best possible length we can have for a rectangle.

  • @singvijaya
    @singvijaya 8 ปีที่แล้ว +6

    Could you explain how to calculate max histogram area without using the library function?

    • @franciscov511
      @franciscov511 5 ปีที่แล้ว +2

      Keeping the smallest of a continuous subset of non zero values

    • @anubhavkumar1637
      @anubhavkumar1637 4 ปีที่แล้ว +2

      You can calculate using stack

  • @ashishdukare1313
    @ashishdukare1313 3 ปีที่แล้ว +1

    Please can you explain why this approach is working? what is the intuition behind it?

  • @DhanunjayG
    @DhanunjayG 8 ปีที่แล้ว +3

    Hi Tushar..first of all thanks a lot for all your efforts..I have learnt a lot from you.
    Can we use and expand the same procedure above to find the largest subcube in a NxNxN cube cosisting of 1x1x1 subcubes with values either 0 or 1. like adding a new dimension to it. If possible can you please suggest the way forward

  • @mirnafayezboules3310
    @mirnafayezboules3310 4 ปีที่แล้ว

    Really you are amazing .. One of the best

  • @arnavsingh0
    @arnavsingh0 4 ปีที่แล้ว

    Although you explain things pretty easily but they are to be memorized if we go by your way.

  • @gauravmamgain9225
    @gauravmamgain9225 8 ปีที่แล้ว

    You are awesome. Your videos helped me a lot . Thanks man :)

  • @chaitanyadumpa2439
    @chaitanyadumpa2439 5 ปีที่แล้ว +2

    Thank you Gautam gambhir

  • @kkaabbccdd8080
    @kkaabbccdd8080 7 ปีที่แล้ว +6

    I would have really appreciated if you could have spent 1 min on code implementation at very high top level. +1 for your efforts on explanation.

  • @huynguyenquang1993
    @huynguyenquang1993 3 ปีที่แล้ว

    Great explanation

  • @devendrasharma7999
    @devendrasharma7999 8 ปีที่แล้ว

    Thanks sir, this video made this question very easy .

  • @mateuszlewicki7616
    @mateuszlewicki7616 8 ปีที่แล้ว

    +Tushar Roy
    You write this algorithm has O(rows * columns) complexity. This suggests that finding rectangle in histogram is solvable in O(1) - this feels very wrong.

  • @aprofromuk
    @aprofromuk 7 ปีที่แล้ว +1

    @Tushar any idea how to compute the largest cross please?

  • @jessematty8788
    @jessematty8788 5 ปีที่แล้ว +1

    nice video but how is an area of 5 a rectangle?

  • @sayeesh3236
    @sayeesh3236 3 ปีที่แล้ว

    Good one Tushar!!!

  • @ethantestimon9905
    @ethantestimon9905 8 ปีที่แล้ว

    Hi Tushar...
    I have one question: why the algorithm of maximum size square of all 1's will not work here?

  • @quirkyquester
    @quirkyquester 3 ปีที่แล้ว

    amazing explanation! Thank you!

  • @ameyapatil1139
    @ameyapatil1139 3 ปีที่แล้ว

    Looking at leetcode - Would temp[j]++ work instead of temp[j] += input[i][j]; on line 40 ?

  • @karanpathak528
    @karanpathak528 3 ปีที่แล้ว

    Hello Tushar awesome explanation
    can you pls advice book/wiki for this algorithm.

  • @ivanonyshchenko
    @ivanonyshchenko 3 ปีที่แล้ว

    I am looking for explanation how to come to the described algorithm, but instead see what to do without explaining why

  • @saumya1857
    @saumya1857 8 ปีที่แล้ว

    Thankyou .you made DP so easy .

  • @7x34hj
    @7x34hj 6 ปีที่แล้ว

    Do you have any videos Maximum Distance Matrices (MDS)? If not, could you do a quick one? Thx

  • @varunsuryan1021
    @varunsuryan1021 3 ปีที่แล้ว

    You are a gem, mate.

  • @jatinkumar4410
    @jatinkumar4410 3 ปีที่แล้ว

    nice explanation

  • @Hystrix008
    @Hystrix008 4 ปีที่แล้ว

    Nice explanation, thank you : )

  • @dongreak4478
    @dongreak4478 5 ปีที่แล้ว

    how do you find the largest multiplication value in each row?

  • @j50313j50313
    @j50313j50313 4 ปีที่แล้ว

    Extremely helpful!

  • @wozhendeaa
    @wozhendeaa 7 ปีที่แล้ว

    with the following case
    100
    010
    110
    if we use the largest rectangle method wouldn't his case result be 4?(2 in the first col and 2 in the second col)

    • @wozhendeaa
      @wozhendeaa 7 ปีที่แล้ว

      but the actual result is 2

    • @brandonm1088
      @brandonm1088 7 ปีที่แล้ว +2

      1] 100 MAX is 1
      2] 010 MAX is 1
      3] 120 MAX is 2
      When a row has a zero in it, it overrides the value in that slot, if that didn't happen then row three would have returned 220, which as we know is incorrect. Hope that helps, I don't think he explicitly mentions that behavior in the video, but it's there

  • @torrtuganooh2484
    @torrtuganooh2484 4 ปีที่แล้ว

    why do we add from the top in case of 1. Can anyone please explain?

  • @tatinenimaheshbabu7344
    @tatinenimaheshbabu7344 8 ปีที่แล้ว

    Thanks for such a good video..

  • @Ilsk8q
    @Ilsk8q 5 ปีที่แล้ว

    You made it really easy to understand, thank you

  • @justanaverageguy4739
    @justanaverageguy4739 3 ปีที่แล้ว

    great sir great thank you

  • @p111calcutta1
    @p111calcutta1 8 ปีที่แล้ว

    good explanation, thanks !!

  • @code_life4835
    @code_life4835 4 ปีที่แล้ว

    what is the Intuition behind this working?

  • @SanjayKumar-jz3gf
    @SanjayKumar-jz3gf 6 ปีที่แล้ว +1

    Is there a way to find indexes of largest rectangle?

    • @lakshaykapoor6559
      @lakshaykapoor6559 6 ปีที่แล้ว

      Just store the row no. when u update the max_area first time and last time. For column no. get the indexes of the array when u calculate its area in histogram.

  • @hobokenbloomfiled8356
    @hobokenbloomfiled8356 9 ปีที่แล้ว

    Another way to find max area would be
    area = max ((min * length of longest consecutive array), (highestValue in the array))

    • @hobokenbloomfiled8356
      @hobokenbloomfiled8356 9 ปีที่แล้ว

      ***** so in your video the last histogram values are 0 0 3 4 2 4
      According to my suggestion
      length of longest consecutive array is 4
      min value in the consecutive array is 2
      highest value is 4
      area = max ((min * length of longest consecutive array), (highestValue in the array))
      area = max((2*4),4)
      area = max(8,4)
      area = 8
      Time complexity O(length of the histogram array)
      Another example
      histogram array values 0 6 0 2 1 0
      length of longest consecutive array is 2
      min value in the consecutive array is 1
      highest value is 6
      area = max ((min * length of longest consecutive array), (highestValue in the array))
      area = max((1*2),6)
      area = max(2,6)
      area = 6
      Correct me if my solution seems wrong.

    • @hobokenbloomfiled8356
      @hobokenbloomfiled8356 9 ปีที่แล้ว

      ***** Makes sense I did realize that once I posted the comment. Although we could still use the formula for each consecutive array and compare the current max to the previous max .. and at the end of the array we can get the max of the entire array.
      9,0,3,3,3,3,,0,1,1,1,1,1,1,1,1
      Set arrayMax = 0
      First Check
      max(9,0)
      arrayMax = 9;
      Second Check
      max(9,12)
      arrayMax=12;
      Third Check
      max(12,8)
      arrayMax =12
      end of the array return arrayMax;
      So my formula would change to
      arrayMax = max ((min value in consecutive array * length of consecutive array), arrayMax);

    • @hobokenbloomfiled8356
      @hobokenbloomfiled8356 9 ปีที่แล้ว

      ***** Agreed did not consider this use case. Yeah my solution would return 5 in this case . But the max area should be 6. Is that correct? I just went down the rabbit hole trying to come up with a solution to it. Thanks for all the use cases.

  • @kartikkumar-6009
    @kartikkumar-6009 2 ปีที่แล้ว +1

    hey it is not a dp approach so Y ur title include dp

  • @HadisKianpour-iw2ni
    @HadisKianpour-iw2ni 3 หลายเดือนก่อน

    why 8? i cant undrestand:(

  • @yernartalgatuly4252
    @yernartalgatuly4252 8 ปีที่แล้ว

    in which video did you discuss maximum size square in matrix?

  • @saikarthikcheedella4301
    @saikarthikcheedella4301 7 ปีที่แล้ว

    thats really cool .....nice explination.

  • @javawicode
    @javawicode 7 ปีที่แล้ว

    how to solve problem when we want found maximum rectangle with- all of 0s

    • @avinashkumar805
      @avinashkumar805 7 ปีที่แล้ว +2

      convert 0 to 1 and 1 to 0 in the array and then do the same process on the new matrix.

  • @guneettalwar2630
    @guneettalwar2630 3 ปีที่แล้ว

    Whats the intuition behind this?

  • @GinoMtzRamos
    @GinoMtzRamos 5 ปีที่แล้ว

    tushar, you are my hero

  • @mshyamkrishnan
    @mshyamkrishnan 8 ปีที่แล้ว

    Is it possible to adapt this algorithm to find out biggests border with 1s ? (which means the inside of the subrectangle need not be 1) ? Great video btw!

    • @shubham277
      @shubham277 4 ปีที่แล้ว

      Bro, in samsung they asked me this problem to find out biggests border with 1s and I could not make any progress.

  • @pranjalabhishek7566
    @pranjalabhishek7566 4 ปีที่แล้ว +3

    In your videos there is one issue, You should first explain the approach on the basis of test cases and slowly move towards building the algorithm. I meant to say that how we can approach a new problem that should be discussed .The solutions to problem can be found anywhere but only to understand the journey which lead to that solution we watch the videos. Thanks

  • @andriibogachenko2537
    @andriibogachenko2537 8 ปีที่แล้ว

    what if rows could be changing the places ? hm....

  • @glacieredge6311
    @glacieredge6311 5 ปีที่แล้ว +1

    Nice video. And recthaangle. Haha 😀

  • @nuamaaniqbal6373
    @nuamaaniqbal6373 2 ปีที่แล้ว

    Thanks man!

  • @aishwaryabadgujar7532
    @aishwaryabadgujar7532 7 ปีที่แล้ว

    +Tushar Roy, this method works for all examples?
    Suppose the 5x5 2D matrix is
    1 0 0 0 1
    0 1 1 1 0
    1 1 1 1 0
    0 0 1 1 1
    1 1 1 1 0
    According to your method, the answer 4. Whereas the answer should be 6 (or 8 if you consider the vertical rectangle)
    Please help!

    • @dhirajdwivedi3530
      @dhirajdwivedi3530 7 ปีที่แล้ว

      ya this algo will work for all examples, for your example too
      for 1st row 1 0 0 0 1 max rectangle is 1
      for 2nd row 0 1 1 1 0 max rectangle is 3 i.e. largest rectangle in histogram made by this array
      for 3rd row 1 2 2 2 0 max rectangle is 6
      for 4th row 0 0 3 3 0 max rectangle is 6
      for 5th row 1 1 4 4 0 max rectangle is 8
      hence your answer i hope u got it 1 1 4 4 0 all indicates the height of histogram at each index of width 1 unit and u have to find the max area in each histogram and compare with the last one

    • @aishwaryabadgujar7532
      @aishwaryabadgujar7532 7 ปีที่แล้ว

      Oh. For the third row, you do not consider that 1 while taking the max rectangle? If you take that 1, the max rectangle will be 4. So will have to apply some algorithm to choose the elements that form the max rectangle instead of considering all the non zero elements. Thanks for your help!

    • @ShinAkuma
      @ShinAkuma 6 ปีที่แล้ว

      You do consider that 1. He probably overlooked it. Row 3 = 00331. However this doesn't affect the maxArea.
      since max rectangle at this point will be:
      111
      111

  • @rajeshpany7017
    @rajeshpany7017 4 ปีที่แล้ว

    It not working for all case

  • @aquibansari3941
    @aquibansari3941 5 ปีที่แล้ว +2

    Ye sahi banda h!
    Like comment if your think the same!

  • @bryanbocao4906
    @bryanbocao4906 6 ปีที่แล้ว +1

    Maybe a 3D histogram?

  • @pavithras7936
    @pavithras7936 3 ปีที่แล้ว +1

    Max sum😍😍😍😍😍

  • @sheetalshireen
    @sheetalshireen 8 ปีที่แล้ว

    Hi Tushar...Thanks for helpful video..1 query - how to handle non contiguous array like 0,0,2,0,0,2.

    • @sheetalshireen
      @sheetalshireen 8 ปีที่แล้ว +1

      +Sheetal according to your code, its giving area = 0...please correct if something is missing

    • @sheetalshireen
      @sheetalshireen 8 ปีที่แล้ว

      lets take example of 1,0,1,0.. and when we run following line after reaching last 0 (i==3) else
      {
      area = arr[top] * i;
      }...it will give 1*3 = 3 (where arr[top] =1 & i =3)

  • @tapanjeetroy8266
    @tapanjeetroy8266 5 ปีที่แล้ว

    Thank you sir

  • @gautamrchavan
    @gautamrchavan 9 ปีที่แล้ว

    @2:44, the value should be 1

    • @gautamrchavan
      @gautamrchavan 9 ปีที่แล้ว

      ***** sorry my bad. I didn't listen to it clearly.
      Btw, great set of videos. Keep up the good work.

  • @karangautam8832
    @karangautam8832 7 ปีที่แล้ว

    anyone can tell me how to find starting index of rectangle in this question

    • @ShinAkuma
      @ShinAkuma 6 ปีที่แล้ว

      A noob programmer like me would take these few variable.
      startI , startJ and run a loop from
      startI=0 till less than maxArea
      startJ=0 till less than maxArea
      Search if all values in this range are 1's. If you find a 0. Just shift this whole Window accordingly till you find the rectangle.
      Though this probably isnt the best way to do it, but I'm a noob and that's how I did it.

  • @shivendrakadam7596
    @shivendrakadam7596 5 ปีที่แล้ว +1

    I think time complexity is O(RC^2)

  • @surekhagaikwad2801
    @surekhagaikwad2801 4 ปีที่แล้ว

    how we can do it for parallelogram?

    • @aatifnazar1766
      @aatifnazar1766 4 ปีที่แล้ว

      how do you represent parallelogram in a data structure?

  • @himeshk187
    @himeshk187 8 ปีที่แล้ว

    Awesome !

  • @Simoni1203
    @Simoni1203 4 ปีที่แล้ว +7

    Better to explain the logics first before throwing in the solution.

  • @kalytheo
    @kalytheo 7 ปีที่แล้ว +1

    Thank you for everything! You are amazing!
    However, I believe this theory does not work for the following example (the number of lines is n=5 and the number of columns is m=5):
    5 5
    0 1 0 1 1
    0 1 1 1 1
    0 1 0 1 1
    0 1 1 1 1
    0 1 1 1 1

    • @TheBD0000
      @TheBD0000 7 ปีที่แล้ว

      it will work.. answer will be 10

  • @LearnAI-andML
    @LearnAI-andML 7 ปีที่แล้ว

    just Awsome

  • @aatifnazar1766
    @aatifnazar1766 4 ปีที่แล้ว

    mind = blown!

  • @1Kapachow1
    @1Kapachow1 8 ปีที่แล้ว

    First of all, thanks for your videos, you've created a very wide collection :)
    Either you are missing a step or I'm missing something. Here's an example:
    I isolated the problem to a very simple test case.
    Imagine that your matrix is a very simple one
    10
    01
    your first histogram will be:
    10
    max area is 1
    using your accumulation method, the second histogram will become
    11
    the max area is 2
    which brings us to final answer of 2, which is obviously not a valid answer.
    Am I missing something here ? Any feedback is welcome :)

    • @1Kapachow1
      @1Kapachow1 8 ปีที่แล้ว

      +Tushar Roy
      Thanks, now it makes sense
      :)

  • @diegocondori5673
    @diegocondori5673 3 ปีที่แล้ว

    thanks :)

  • @vinayak186f3
    @vinayak186f3 3 ปีที่แล้ว

    Thanks

    • @vinayak186f3
      @vinayak186f3 3 ปีที่แล้ว

      Keep visiting again n again you fool 😠

  • @HarishAmarnath
    @HarishAmarnath 3 ปีที่แล้ว

    This is wrong ! If we swap index 2,4 to 1,4 we ll still get same answer , but the matrix is not all made of 1's ..check at 5:53

  • @arka.outside
    @arka.outside 6 ปีที่แล้ว

    You are GOD !

  • @amankumar-set
    @amankumar-set 13 วันที่ผ่านมา

    But how to calculate max histogram area.😂

  • @namangrover1989
    @namangrover1989 6 ปีที่แล้ว +2

    Time Complexity should be O( rows * cols^2)

  • @suniljaiswal2471
    @suniljaiswal2471 4 ปีที่แล้ว +1

    check the code here also if you want
    cpincpp.blogspot.com/2020/09/maximal-rectangle-in-given-matrix-with.html

  • @lifecodesher5818
    @lifecodesher5818 4 ปีที่แล้ว

    are you a robot

  • @helloeveryone2749
    @helloeveryone2749 9 ปีที่แล้ว

    suppose my row value were 3 3 4 2 then max area acc to you would have been 8 but 9 is the max value.

    • @AmitDhiman000
      @AmitDhiman000 9 ปีที่แล้ว +1

      +The rock
      first check the histogram area calculation algorithm video,
      then you will come to know every thing is proper.