Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction To Data Mining

Authors: Pang Ning Tan, Michael Steinbach, Vipin Kumar

1st Edition

321321367, 978-0321321367

More Books

Students also viewed these Databases questions

Question

What is a polytomous variable?

Answered: 1 week ago

Question

1.2 Describe who performs HRM.

Answered: 1 week ago