FastPrepFastPrep
Problem Brief

Find Longest Diagonal Segment

INTERNOA

Plz check out the source image below for the original problem statement :)

1Example 1

Input
matrix = [[0, 0, 1, 2], [0, 2, 2, 2], [2, 1, 0, 1]]
Output
3
Explanation
Just my educated guess. might be right might be wrong - The longest diagonal segment following the pattern 1, 2, 0, 2, 0, 2, 0, ... can be found starting from the element at row 2, column 1 (1-based index), going up and to the right. The segment is [1, 2, 0], which has a length of 3.
public int solution(int[][] matrix) {
  // write your code here
}
Input

matrix

[[0, 0, 1, 2], [0, 2, 2, 2], [2, 1, 0, 1]]

Output

3

Sign in to submit your solution.