Ctrl K

Present in Every List

Easy
You are given lists, a list of integer lists; no number repeats within a single list. Find the numbers that appear in every one of the lists and return them in increasing order. If there are none, return an empty list.
Example 1
lists=[[4, 9, 2], [9, 7, 4, 1], [3, 4, 9]] → [4, 9]

Both 4 and 9 appear in all three lists; no other number does. In increasing order: [4, 9].

Example 2
lists=[[5, 6], [7]] → []

There are no common numbers, so the answer is empty.

Example 3
lists=[[8, 3, 5]] → [3, 5, 8]

With a single list, all of its numbers qualify, sorted.

Constraints
  • 1 ≤ len(lists) ≤ 1000
  • 1 ≤ total number of elements ≤ 1000
  • 1 ≤ lists[i][j] ≤ 1000
  • The numbers within each lists[i] are distinct
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsThe Candidate With Most Votes EasyValues One Apart EasyMore Than a Third of the Votes MediumMost Common Values MediumJobs With a Cooldown Medium
loading Python…
Input
lists=[[4, 9, 2], [9, 7, 4, 1], [3, 4, 9]]
Expected
[4, 9]

Run checks the first 3 tests in your browser. Submit checks all 96 tests on the server, hidden ones included.