We have a 2D matrix A of M rows where each row is filled with a permutation of natural numbers from 1 to N (A[M][N])
We have to determine the length of the longest common Subarray among all the rows of the matrix
Example :
A = {{1,2,3,4},{3,4,1,2},{3,1,2,4}}
Longest common Subarray {1,2}
Length of LCS = 2
Output = 2
I don't need the code just a suggestion for optimization.