天天看點

leetCode 85.Maximal Rectangle (最大矩陣) 解題思路和方法

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組成的最大矩陣的面積。

此題能夠巧妙轉化為求最大直方圖面積的問題。

詳細代碼和思路例如以下: