Skip to content

Latest commit

 

History

History
81 lines (42 loc) · 1.6 KB

README_EN.md

File metadata and controls

81 lines (42 loc) · 1.6 KB

中文文档

Description

Imagine you have a square matrix, where each cell (pixel) is either black or white Design an algorithm to find the maximum subsquare such that all four borders are filled with black pixels.

Return an array [r, c, size], where rc are the row number and the column number of the subsquare's upper left corner respectively, and size is the side length of the subsquare. If there are more than one answers, return the one that has smallest r. If there are more than one answers that have the same r, return the one that has smallest c. If there's no answer, return an empty array.

Example 1:

Input:

[

   [1,0,1],

   [0,0,1],

   [0,0,1]

]

Output: [1,0,2]

Explanation: 0 represents black, and 1 represents white, bold elements in the input is the answer.

Example 2:

Input:

[

   [0,1,1],

   [1,0,1],

   [1,1,0]

]

Output: [0,0,1]

Note:

  • matrix.length == matrix[0].length <= 200

Solutions

Python3

Java

...