Skip to content

Latest commit

 

History

History
6 lines (5 loc) · 333 Bytes

File metadata and controls

6 lines (5 loc) · 333 Bytes

greedy

We can count the number of consecutive 1 in each of the spot from top to down.
We can iterator through each row of the consecutive 1s. We can sort the row int descending order, because puting largest in the front we can always us height[i] * (i + 1) to update the matrix area.

time: O(n * (n + nlogn))
space: O(n)