Given a matrix that contains only 1s and 0s, find the largest X shape which contains only 1s, with the same arm lengths and the four arms joining at the central point.
Return the arm length of the largest X shape.
Assumptions
- The given matrix is not null, has size of N * M, N > = 0 and M > = 0.
Examples
{ {0, 0, 0, 0},
{1, 1,1, 1},
{0,1, 1, 1},
{1, 0,1, 1} }
the largest X of 1s has arm length 2.
Approach: Similar to the largest cross. the direction get changed. we need preprocess the left__up--> right__bottom
right_ up-->left\ bottom , left_bottom-->right_up, and right_bottom to left_up directions. _
Step2: for each position m[i][j], find the min(4 preprocessed matrix in that position). if (m[i][j] > max) max = m[i][j] return max.