1139. Largest 1-Bordered Square Medium
1/**
2 * [1139] Largest 1-Bordered Square
3 *
4 * Given a 2D grid of 0s and 1s, return the number of elements in the largest square subgrid that has all 1s on its border, or 0 if such a subgrid doesn't exist in the grid.
5 *
6 *
7 * Example 1:
8 *
9 *
10 * Input: grid = [[1,1,1],[1,0,1],[1,1,1]]
11 * Output: 9
12 *
13 *
14 * Example 2:
15 *
16 *
17 * Input: grid = [[1,1,0,0]]
18 * Output: 1
19 *
20 *
21 *
22 * Constraints:
23 *
24 *
25 * 1 <= grid.length <= 100
26 * 1 <= grid[0].length <= 100
27 * grid[i][j] is 0 or 1
28 *
29 */
30pub struct Solution {}
31
32// problem: https://leetcode.com/problems/largest-1-bordered-square/
33// discuss: https://leetcode.com/problems/largest-1-bordered-square/discuss/?currentPage=1&orderBy=most_votes&query=
34
35// submission codes start here
36
37impl Solution {
38 pub fn largest1_bordered_square(grid: Vec<Vec<i32>>) -> 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_1139() {
51 }
52}
53
Back
© 2025 bowen.ge All Rights Reserved.