Search⌘ K

Find the Smallest Common Number

Explore how to identify the smallest common element among three sorted integer arrays by using simultaneous iterators. Understand the linear time and constant space complexity approach that helps efficiently traverse all arrays and find a common number or return -1 if none is found. This lesson enhances your skills in array manipulation and algorithm optimization.

Statement

We’re given three integer arrays, each sorted in ascending order. Return the smallest number common in all three arrays. In case no number is common, return -1.

Example

Let’s look at the three arrays below, where 66​ is the smallest number that is common in all the arrays:

g array 6 7 10 25 30 63 64 array2 0 4 5 6 7 8 50 array3 1 6 10 14

Sample input

v1 = [6, 7, 10, 25, 30, 63, 64]
v2 = [0, 4, 5, 6,
...