Maximum Length Of Repeated Subarray

easy
1.Given two integer arrays A and B
 2.You have to complete the function max() that should return the maximum length of an subarray that appears in both arrays.

Input Format

First line contains an Integer 'N' denoting the size of the array A. Second line contains 'N' space separated elements of the array A. Third line contains an Integer 'M' denoting the size of the array B. Fourth line contains 'M' space separated elements of the array B.

Output Format

Return an Integer

Constraints

1 <= len(A), len(B) <= 1000
 0 <= A[i], B[i] < 100

Notice

Try First, Check Solution later

1. You should first read the question and watch the question video.
2. Think of a solution approach, then try and submit the question on editor tab.
3. We strongly advise you to watch the solution video for prescribed approach.

Example

Input
5
1 2 3 2 1
5
3 2 1 4 7
Output
3
Previous
Maximum Difference Of Zeros And Ones In Binary String
Next
Maximum Sum Increasing Subsequence

Related Questions