LeetCode 718, Medium. Topics: Array, Binary Search, Dynamic Programming, Sliding Window, Rolling Hash, Hash Function. View on LeetCode.
Generate this problem as a practice environment: tested reference solution, 24 parametrized pytest cases, and a playground notebook:
Problem
Given two integer arrays nums1 and nums2, return the maximum length of a subarray that appears in both arrays.
Examples
Constraints
- 1 <= nums1.length, nums2.length <= 1000
- 0 <= nums1[i], nums2[i] <= 100
Solution
Reference implementation from solution.py on GitHub, full suite in test_solution.py:
Complexity
Last modified on September 7, 2026