Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 6420 |

@blackshadows | 6380 |

@mb1973 | 5642 |

@Quandray | 5233 |

@akhayrutdinov | 5111 |

@saiujwal13083 | 4610 |

@sanjay05 | 3762 |

@kirtidee18 | 3673 |

@marius_valentin_dragoi | 3522 |

@sushant_a | 3459 |

@verma_ji | 3413 |

Complete Leaderboard | |

Handle | Score |

@sanskar94511 | 603 |

@akashverma4 | 363 |

@swastik8750 | 300 |

@nishunishuraj18 | 286 |

@surajmamgai | 264 |

@anks9013 | 222 |

@nayan2709 | 213 |

@burhanuddinbohra72 | 212 |

@amank8975 | 203 |

@realname | 203 |

@manmeetkaur18102000 | 202 |

Complete Leaderboard |

Given a binary matrix. Find the maximum area of a rectangle formed only of 1s in the given matrix.

**Example 1:**

Input:n = 4, m = 4 M[][] = {{0 1 1 0}, {1 1 1 1}, {1 1 1 1}, {1 1 0 0}}Output:8Explanation:For the above test case the matrix will look like 0 1 1 0 1 1 1 1 1 1 1 1 1 1 0 0 the max size rectangle is 1 1 1 1 1 1 1 1 and area is 4 *2 = 8.

**Your Task: **

Your task is to complete the function **maxArea** which returns the maximum size rectangle area in a binary-sub-matrix with all 1’s. The function takes 3 arguments the first argument is the Matrix M[ ] [ ] and the next two are two integers n and m which denotes the size of the matrix M.

**Expected Time Complexity** : O(n*m)

**Expected Auixiliary Space** : O(m)

**Constraints:**

1<=n,m<=1000

0<=M[][]<=1

**Note:**The **Input/Ouput** format and **Example** given are used for system's internal purpose, and should be used by a user for **Expected Output** only. As it is a function problem, hence a user should not read any input from stdin/console. The task is to complete the function specified, and not to write the full code.

Login to report an issue on this page.

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes
Max rectangle

...