FastPrepSmallest Common Integer in Sorted Lists
Problems/Smallest Common Integer in Sorted Lists

Smallest Common Integer in Sorted Lists

Motive logoMotive● MediumFULLTIMEONSITE INTERVIEW

Updated Sep 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A first-hand Motive onsite report asks for the smallest integer shared by a collection of sorted integer lists. Nonempty lists, nonnegative values, duplicate handling, and -1 for no common value are explicit practice assumptions; the reported core matches at about 88%.

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[][]) → int

Examples

Example 1

lists = [[1,2,3,4],[0,2,4],[2,5,9]]return = 2

The value 2 appears in all three lists, and no smaller value does.

Example 2

lists = [[1,2],[3,4]]return = -1

The two lists have no common integer.

Example 3

lists = [[0,0,1],[0,2],[0,0,3]]return = 0

Duplicate 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 most 200000.
  • 0 <= lists[i][j] <= 1000000000.
  • Every inner list is sorted in nondecreasing order.

More Motive Onsite Interview questions

  • Group AnagramsPHONE SCREEN · ONSITE INTERVIEW · Seen Jan 2026
  • Longest Equal-Zero-One SubarrayPHONE SCREEN · ONSITE INTERVIEW · Seen Jan 2026
  • Maximum Weighted Sum After Left RotationsONSITE INTERVIEW · Seen Jan 2026
  • Valid Parenthesis StringPHONE SCREEN · ONSITE INTERVIEW · Seen Jan 2026
  • Best Time to Buy and Sell StockONSITE INTERVIEW · Seen Dec 2025
  • Target Triplet SumONSITE INTERVIEW · Seen Dec 2025
  • Validate IP AddressONSITE INTERVIEW · Seen Dec 2025
  • Generate Palindromic PermutationsONSITE INTERVIEW · Seen Dec 2025
  • Minimum Swaps to Group Circular OnesONSITE INTERVIEW · Seen Dec 2025
  • Staircase Search In A Sorted MatrixONSITE INTERVIEW · Seen Dec 2025

Similar questions at other companies

  • 3Sum SmallerSalesforce · ONSITE INTERVIEWSalesforce interview questions
  • Maximize the Minimum Distance Between RobotsAmazon · ONSITE INTERVIEW
  • Streaming Triple Packing by Size ThresholdGoogle · ONSITE INTERVIEWGoogle interview questions
  • Maximum Total Length of Non-Overlapping IntervalsBloomberg LP · ONSITE INTERVIEWBloomberg LP interview questions
  • Room Occupancy at Query TimesWhatNot · ONSITE INTERVIEWWhatNot interview questions
  • HTTP Log QueriesDatadog · PHONE SCREEN · ONSITE INTERVIEWDatadog interview questions
  • Russian Doll EnvelopesInMobi · ONSITE INTERVIEWInMobi interview questions
  • Find Unmet Users With Shared InterestsPalantir · ONSITE INTERVIEWPalantir interview questions
  • Count Later Lower ReadingsRippling · ONSITE INTERVIEWRippling interview questions
  • Russian Doll EnvelopesAirbnb · ONSITE INTERVIEWAirbnb interview questions
All Motive interview questionsSee Motive hiring insights
Saved
class Solution {
    public int smallestCommonInteger(int[][] lists) {
        // write your code here
    }
}
Checking account…