Find longest common contiguous subarray
AmazonSoftware Engineer · OnsiteLast updated
This question evaluates a candidate's proficiency in array and substring algorithm design, including concepts such as dynamic programming, hashing, and efficient search techniques.
Given two integer arrays A and B, find the length of the longest contiguous subarray that appears in both arrays. If multiple exist, return any one pair of starting indices as well. Discuss possible approaches (e.g., dynamic programming, binary search with rolling hash) and analyze time and space complexity.
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.