Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def solution(n, m, arr1, arr2):
- dp = [0 for _ in range(m+1)]
- res_max = 0
- for i in range(n-1, -1, -1):
- for j in range(m):
- if arr1[i] == arr2[j]:
- dp[j] = dp[j+1] + 1
- else:
- dp[j] = 0
- res_max = max(res_max, dp[j])
- return res_max
- n = int(input())
- arr1 = list(map(int, input().split()))
- m = int(input())
- arr2 = list(map(int, input().split()))
- print(solution(n, m, arr1, arr2))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement