Given a sorted array `elements` of length `n` and a target sequence `target` of length `m`, find the index of the first occurrence of the sequence in `elements`. If the sequence is not found, return -1.
Explanation: The sequence [2, 3, 4] starts at index 1 in the array [1, 2, 3, 4, 5, 6]
Explanation: The sequence [7, 8, 9] is not found in the array [1, 2, 3, 4, 5, 6]
Analyze constraints and compute optimal solutions step-by-step.
No dry run loaded.
🚀 Practice this problem
Run code, get AI hints & track streak