Implement a function that would give you the longest incrementing path in a 2d array. You can only move to adjacent values (not diagonally).
Sigiloso
Python: def longest_inc_path(matrix): longest, current = None, None for j in matrix: for k in matrix[j]: # If we are on the first cell if longest is None and current is None: longest, current = matrix[j][k], matrix[j][k] continue # Decide if we are to our current sum or starting # over with the current cell. current = max(matrix[j][k], longest + matrix[j][k]) # Decide if our current sum is longer than our longest # sum so far. longest = max(longest, current) return longest