764. Largest Plus Sign Medium

@problem@discussion
#Array#Dynamic Programming



1/**
2 * [764] Largest Plus Sign
3 *
4 * You are given an integer n. You have an n x n binary grid grid with all values initially 1's except for some indices given in the array mines. The i^th element of the array mines is defined as mines[i] = [xi, yi] where grid[xi][yi] == 0.
5 * Return the order of the largest axis-aligned plus sign of 1's contained in grid. If there is none, return 0.
6 * An axis-aligned plus sign of 1's of order k has some center grid[r][c] == 1 along with four arms of length k - 1 going up, down, left, and right, and made of 1's. Note that there could be 0's or 1's beyond the arms of the plus sign, only the relevant area of the plus sign is checked for 1's.
7 *  
8 * Example 1:
9 * <img alt="" src="https://assets.leetcode.com/uploads/2021/06/13/plus1-grid.jpg" style="width: 404px; height: 405px;" />
10 * Input: n = 5, mines = [[4,2]]
11 * Output: 2
12 * Explanation: In the above grid, the largest plus sign can only be of order 2. One of them is shown.
13 * 
14 * Example 2:
15 * <img alt="" src="https://assets.leetcode.com/uploads/2021/06/13/plus2-grid.jpg" style="width: 84px; height: 85px;" />
16 * Input: n = 1, mines = [[0,0]]
17 * Output: 0
18 * Explanation: There is no plus sign, so return 0.
19 * 
20 *  
21 * Constraints:
22 * 
23 * 	1 <= n <= 500
24 * 	1 <= mines.length <= 5000
25 * 	0 <= xi, yi < n
26 * 	All the pairs (xi, yi) are unique.
27 * 
28 */
29pub struct Solution {}
30
31// problem: https://leetcode.com/problems/largest-plus-sign/
32// discuss: https://leetcode.com/problems/largest-plus-sign/discuss/?currentPage=1&orderBy=most_votes&query=
33
34// submission codes start here
35
36impl Solution {
37    pub fn order_of_largest_plus_sign(n: i32, mines: Vec<Vec<i32>>) -> i32 {
38        0
39    }
40}
41
42// submission codes end
43
44#[cfg(test)]
45mod tests {
46    use super::*;
47
48    #[test]
49    fn test_764() {
50    }
51}
52


Back
© 2025 bowen.ge All Rights Reserved.