20
Oct

Given an m-by-n matrix with positive integers, determine the length of the longest path of increasing within the matrix. For example, consider the input matrix:[1 2 34 5 67 8 9] The answer should be 5 since the longest path would be 1-2-5-6-9 def isValid(mat, i, j): return 0 <= i < len(mat) and 0 <= j < len(mat) def findLongestPath(mat, i, j): if not isValid(mat, i, j): return [] path = [] if i > 0 and mat[i - 1][j] - mat[i][j] == 1: path = findLongestPath(mat, i - 1, j) if j + 1 < len(mat) and mat[i][j…