30:00
Given two integer arrays nums1 and nums2, return the maximum length of a subarray that appears in both arrays.
nums1
nums2
1≤nums1.length,nums2.length≤10001 \leq \text{nums1.length}, \text{nums2.length} \leq 10001≤nums1.length,nums2.length≤1000
0≤nums1[i],nums2[i]≤1000 \leq \text{nums1}[i], \text{nums2}[i] \leq 1000≤nums1[i],nums2[i]≤100
Run code to see results.
Slide nums2 underneath nums1 one position at a time. In each alignment, a shared subarray is a run of equal pairs stacked on top of each other.
nums1 fixed on top, nums2 slides underneath
longest shared run so far
none yet
shift
-
run
0
best
Given two integer arrays, return the length of the longest contiguous block that appears in both.