109: Maximum length of repeated subarray

Given two integer arrays, return the maximum length of a subarray that exists in both arrays

 

Example 1

Input:   array1 = [1, 1, 4, 5, 3], array2 = [10, 1, 4, 15]

Output:  2

Explanation: [1, 4]

Example 2

Input:   array1 = [1, 1, 4, 5, 3], array2 = [10, 7, 8, 15]

Output:  0
Difficulty:Medium
Topic:Dynamic programming
Problem #:109