Get Maximum Length of Repeated Subarray Using Sliding Window
Link : https://leetcode.com/problems/maximum-length-of-repeated-subarray/description/
class Solution:
def findLength(self, nums1: List[int], nums2: List[int]) -> int:
ans = 0
current = ""
findString = "-"
for e in nums2:
findString += str(e) + "-"
for right in range(len(nums1)):
current += str(nums1[right]) + "-"
if "-" + current not in findString:
current = current[current.find("-") + 1: ]
else:
x = len(current[:-1].split("-"))
ans = max(ans, x)
return ans