Leetcode 764. Largest Plus Sign

Input: n = 5, mines = [[4,2]]
Output: 2
Explanation: In the above grid, the largest plus sign can only be of order 2. One of them is shown.
Input: n = 1, mines = [[0,0]]
Output: 0
Explanation: There is no plus sign, so return 0.
  • 1 <= n <= 500
  • 1 <= mines.length <= 5000
  • 0 <= xi, yi < n
  • All the pairs (xi, yi) are unique.
  1. find the largest PLUS sign, return the length from plus heart to plus arm
  2. create a new matrix, and fill all of them into 1, change mines to 0
  3. loop through the matrix, and if we see 0, change the matrix[i][j] into 0
  4. catch the max result at the end of the loop

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store