first and second. Find the longest contiguous run of elements that appears in both arrays, and return its length.
If the arrays share no elements, return 0.first=[7, 2, 5, 5, 9, 1], second=[3, 2, 5, 5, 4] → 3
The run [2, 5, 5] appears contiguously in both arrays, so the length is 3.
first=[1, 2, 3], second=[3, 2, 1] → 1
The arrays share elements, but only one matches in a row, so the answer is 1.
first=[6, 6], second=[0, 8, 4] → 0
first=[7, 2, 5, 5, 9, 1], second=[3, 2, 5, 5, 4]
3
Run checks the first 3 tests in your browser. Submit checks all 111 tests on the server, hidden ones included.