Finding the intersection of arrays


Given two sorted arrays of length N, write a function to return the intersection of the arrays.

For example:

[1, 2, 3, 4], [1, 6, 3, 5] -> returns [1,3]

For simplicity, your algorithm can preserve duplicates (e.g. if 1 is listed/intersects twice across the arrays you can return 1 twice in your output array).


Access restricted

Subscribe to premium account to see the solution.

Get premium now