Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area.
思路:此题的意思是给一个为0或1的矩阵,求所有为1组成的最大矩阵的面积。
此题能够巧妙转化为求最大直方图面积的问题。
详细代码和思路例如以下:
Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area.
思路:此题的意思是给一个为0或1的矩阵,求所有为1组成的最大矩阵的面积。
此题能够巧妙转化为求最大直方图面积的问题。
详细代码和思路例如以下: