Problem · Matrix

Find Longest Diagonal Segment

Learn this problem
MediumRoblox logoRobloxINTERNOA
See Roblox hiring insights

Problem statement

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

Function

solution(matrix: int[][]) → int

Examples

Example 1

matrix = [[0, 0, 1, 2], [0, 2, 2, 2], [2, 1, 0, 1]]return = 3
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.

More Roblox problems

drafts saved locally
public int solution(int[][] matrix) {
  // write your code here
}
matrix[[0, 0, 1, 2], [0, 2, 2, 2], [2, 1, 0, 1]]
expected3
checking account