221. Maximal Square Medium

@problem@discussion
#Array#Dynamic Programming#Matrix



1/**
2 * [221] Maximal Square
3 *
4 * Given an m x n binary matrix filled with 0's and 1's, find the largest square containing only 1's and return its area.
5 *  
6 * Example 1:
7 * <img alt="" src="https://assets.leetcode.com/uploads/2020/11/26/max1grid.jpg" style="width: 400px; height: 319px;" />
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: 4
10 * 
11 * Example 2:
12 * <img alt="" src="https://assets.leetcode.com/uploads/2020/11/26/max2grid.jpg" style="width: 165px; height: 165px;" />
13 * Input: matrix = [["0","1"],["1","0"]]
14 * Output: 1
15 * 
16 * Example 3:
17 * 
18 * Input: matrix = [["0"]]
19 * Output: 0
20 * 
21 *  
22 * Constraints:
23 * 
24 * 	m == matrix.length
25 * 	n == matrix[i].length
26 * 	1 <= m, n <= 300
27 * 	matrix[i][j] is '0' or '1'.
28 * 
29 */
30pub struct Solution {}
31
32// problem: https://leetcode.com/problems/maximal-square/
33// discuss: https://leetcode.com/problems/maximal-square/discuss/?currentPage=1&orderBy=most_votes&query=
34
35// submission codes start here
36
37impl Solution {
38    pub fn maximal_square(matrix: Vec<Vec<char>>) -> i32 {
39        0
40    }
41}
42
43// submission codes end
44
45#[cfg(test)]
46mod tests {
47    use super::*;
48
49    #[test]
50    fn test_221() {
51    }
52}
53


Back
© 2025 bowen.ge All Rights Reserved.