Question: Given a matrix that contains only the characters ' 0 ' and ' 1 ' , find the biggest plus sign ( + ) formed

Given a matrix that contains only the characters
'0' and '1', find the biggest plus sign (+) formed by 1 s in this matrix and return its size.
Size, in this case, indicates the length of the plus sign's edges. In order to be a valid plus sign, the edges must be of equal length.
For example, a plus sign with a size of k in matrix starts at cell (x, y). The plus sign's edges are (x - k. y),(x - k +1, y),...,
(x + k, y) and (x, y - k),(x, y - k +
1),..,(x. y + k), all with a length of k .
Example
For
main.cg
1
2
3
}
matrix =["0010010",
"1010101",
"1111111"
"0010000",
"0000000"]
the output should be solution (matrix)=1
Here, the biggest plus sign is centered at cell (2,
2)(O-based) and has a size of 1 since the downward facing edge is short.
1
2
3
4
Input/Output
[execution time limit]0.5 seconds (cpp)
[memory limit]1 GB
[input] array.string matrix
A matrix containing only the symbols '0" and '1'. It is guaranteed that there is at least one 1' in matrix.
Guaranteed constraints:
1<= inputArray. length <=1000,
1<= inputArray[i]. Tength <=5000
[output] integer
The size of the biggest plus sign formed by I sin matrix.
[C++] Syntax Tips

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!