Longest Common Subarray

Can anyone say How to find the Longest Common Subarray of all rows in a matrix where each row have numbers 1 to n.
Ex: matrix:
[ [1,2,3,4]
[4, 1,2,3]] .
Here the answer is 3 ([1, 2,3] is the longest common Subarray).

1 Like