Maximum Length Of Repeated Subarray

medium
1. You are given two arrays of integers arr1 and arr2.
2. You have to find the maximum length of subarray that appears in both the given arrays.

Input Format

A number N a1 a2.. N numbers A number M b1 b2.. M numbers

Output Format

An integer representing the maximum length of repeated subarray.

Constraints

1 <= N,M <= 10^4
0 <= a[i], b[i] <= 10^3

Example

Input
5
5 4 3 2 1
6
7 8 4 3 2 5
Output
3
Previous
Kahn Algorithm
Next
Heaters

Related Questions