Company: Visa__
Difficulty: medium
Longest Diagonal Segment Problem Description Given a matrix of integers, with each element containing either 0, 1, or 2, your task is to find the longest diagonal segment which matches the following pattern: 1, 2, 0, 2, 0, 2, ... (where the first element is 1, and then 2 and 0 are repeating infinitely), and finishes at a matrix border. Return the length of this diagonal segment. The diagonal segment has the following properties: - It must start at a matrix element with the value 1. - It may go toward any of the four possible diagonal directions (up-left, up-right, down-left, down-right). - It must end at an element in the first or last row or column (a matrix border). Note: You are not expected to provide the most optimal solution, but a solution with time complexity not worse than O(matrix.length * matrix[0].length^2) will fit within the execution time limit. Examples Example 1: Input: matrix = [[0, 0, 1, 2], [0, 2, 2, 2], [2, 1, 0, 1]] Output: 3 Explanation: The segment starting at m