Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

Maximal Rectangle

XPChallenge Points: 30
levelLevel: Hard

You are given a 2D grid of '0' and '1' characters.
Find the biggest rectangle made up of only 1s and return its area.

Example 1:

Input: grid = [ ["1","1","0","1"], ["1","1","1","1"], ["1","1","1","0"] ]

Output: 6

Explanation:

The largest rectangle of only 1s is 2 rows × 3 columns = area 6.

Example 2:

Input: grid = [["0","0"]]

Output: 0

Explanation:

No rectangle of 1s exists.

Example 3:

Input: grid = [["1","1"],["1","1"]]

Output: 4

Explanation:

All cells are 1 → rectangle size is 2 × 2 = 4.

to Continue
like
dislike

Accepted:

Submission:

IconReport an issue
Icon
IconCode
IconYou need toto run or submitYou need toto run or submit
IconTest Case
IconTest Result