Largest area of rectangle with permutations

https://www.interviewbit.com/problems/largest-area-of-rectangle-with-permutations/ please help on how to proceed with the problem using the histogram method…

Hi, you can solve this problem by using dynamic programming. So, the approach is

  1. make a 2D array of given matrix’s size
  2. Store the number of consecutive 1’s in every column.
  3. Sort all the rows of 2D array in decreasing order.
  4. Now traverse the 2D arrays and calculate the max area. As every row is sorted by number of 1’s, the current area can be calculated by multiplying column number with value of cell of 2D arrays => curr_area= col_no. * arr[i][j]