This question evaluates the ability to work with sorted arrays, index mapping, duplicate handling, and reasoning about correctness and algorithmic complexity.
Marketing analytics team needs to find common elements between two sorted arrays of user IDs.
Given two sorted integer arrays without duplicates, return the list of index pairs where the elements match, e.g., arr1=[1,4,5,6,7,9], arr2=[1,2,3,6,9] -> [[0,0],[3,3],[5,4]].
Follow-ups:
Discuss possible edge cases.
If the arrays can contain duplicates (arr1=[1,1,4,5,6,6,6,7,9], arr2=[1,2,3,6,6,9,9]), modify your algorithm to return all valid index pairs.
Think two-pointer merge approach; handle duplicates with nested loops; analyze O(n+m) time.