85. Maximal Rectangle Hard
1/**
2 * [85] Maximal Rectangle
3 *
4 * Given a rows x cols binary matrix filled with 0's and 1's, find the largest rectangle containing only 1's and return its area.
5 *
6 * Example 1:
7 * <img alt="" src="https://assets.leetcode.com/uploads/2020/09/14/maximal.jpg" style="width: 402px; height: 322px;" />
8 * Input: matrix = [["1","0","1","0","0"],["1","0","1","1","1"],["1","1","1","1","1"],["1","0","0","1","0"]]
9 * Output: 6
10 * Explanation: The maximal rectangle is shown in the above picture.
11 *
12 * Example 2:
13 *
14 * Input: matrix = [["0"]]
15 * Output: 0
16 *
17 * Example 3:
18 *
19 * Input: matrix = [["1"]]
20 * Output: 1
21 *
22 *
23 * Constraints:
24 *
25 * rows == matrix.length
26 * cols == matrix[i].length
27 * 1 <= row, cols <= 200
28 * matrix[i][j] is '0' or '1'.
29 *
30 */
31pub struct Solution {}
32
33// problem: https://leetcode.com/problems/maximal-rectangle/
34// discuss: https://leetcode.com/problems/maximal-rectangle/discuss/?currentPage=1&orderBy=most_votes&query=
35
36// submission codes start here
37
38impl Solution {
39 pub fn maximal_rectangle(matrix: Vec<Vec<char>>) -> i32 {
40 0
41 }
42}
43
44// submission codes end
45
46#[cfg(test)]
47mod tests {
48 use super::*;
49
50 #[test]
51 fn test_85() {
52 }
53}
54
Back
© 2025 bowen.ge All Rights Reserved.