The Maximum Length of Repeated Subarray coding problem gives you two integer arrays and asks for the length of the longest subarray (contiguous) that appears in both. Unlike subsequences, subarrays must be contiguous. This is related to the longest common substring problem and is a fundamental dynamic programming exercise with connections to string hashing and binary search.
Citadel, Microsoft, Google, Palantir, and Bloomberg include this problem because it has multiple valid approaches at different complexity levels. The DP solution is clean and O(m*n); the rolling hash + binary search approach is more sophisticated and O((m+n) log(min(m,n))). Discussing trade-offs between these approaches demonstrates depth. It also has practical relevance to diff algorithms and sequence alignment.
Dynamic Programming: Define dp[i][j] = length of the longest common subarray ending at A[i-1] and B[j-1]. Transition: if A[i-1] == B[j-1], then dp[i][j] = dp[i-1][j-1] + 1; else dp[i][j] = 0. The answer is the maximum value in the DP table. Time: O(mn), Space: O(mn) or O(min(m,n)) with rolling array.
Binary Search + Rolling Hash: Binary search on the answer length L. For a given L, hash all subarrays of length L in both arrays and check for a common hash. O((m+n) log(min(m,n))) expected.
A = [1, 2, 3, 2, 1], B = [3, 2, 1, 4, 7]
DP table (key cells):
Maximum = 3. The common subarray is [3, 2, 1].
For the Array Hash Function Rolling Hash Sliding Window Binary Search Dynamic Programming interview pattern, start with the DP solution and then mention the binary search + hashing optimization. The DP is interview-friendly for its clarity; the hashing approach shows depth. Both are worth knowing for companies like Citadel and Palantir that probe multiple solution levels.