Find the longest sequence formed by adjacent numbers in the matrix
Given an N × N matrix where each cell has a distinct value in the 1 to N × N. Find the longest sequence formed by adjacent numbers in the matrix such that for each number, the number on the adjacent neighbor is +1 in its value.