Intersection of two sorted arrays
MediumYou're given 2 sorted arrays. Write a function that returns the intersection of the arrays.
For example, given the following sorted arrays
A = [1, 4, 6, 7, 9]B = [2, 4, 5, 6]
Your function should return numbers that exist in both arrays:
[4, 6]
Try it first
Solution
5 Essential Sorting & Searching Coding Interview Problems
Master Sorting & Searching by trying the coding challenges below.
- 1.Merge intervalsMedium
- 2.Kth largest in arrayMedium
- 3.Intersection of ArraysMedium
- 4.Search sorted matrixHard
- 5.Search row & col sorted matrixHard