Smallest Common Integer in Sorted Lists
Problem statement
You are given lists, a collection of integer lists. Every inner list is sorted in nondecreasing order.
Return the smallest integer that appears in every inner list. Repeated copies within one list count as one presence. If no integer appears in every list, return -1.
Function
smallestCommonInteger(lists: int[][]) → intExamples
Example 1
lists = [[1,2,3,4],[0,2,4],[2,5,9]]return = 2The value 2 appears in all three lists, and no smaller value does.
Example 2
lists = [[1,2],[3,4]]return = -1The two lists have no common integer.
Example 3
lists = [[0,0,1],[0,2],[0,0,3]]return = 0Duplicate copies do not matter; 0 is present in every list.
Constraints
1 <= lists.length <= 100.1 <= lists[i].length, and the total number of integers is at most200000.0 <= lists[i][j] <= 1000000000.- Every inner list is sorted in nondecreasing order.