Ctrl K

Values on Every List

Medium
Several warehouses sent lists of the item codes they have in stock. Each list lists[i] is sorted in strictly increasing order. Find the longest sequence that can be obtained from every list by crossing out elements (the rest keep their order). Return it as a list.
Example 1
lists=[[2, 5, 8, 13], [1, 2, 8, 9, 13], [2, 3, 8, 13, 20]] → [2, 8, 13]

All three lists contain 2, 8 and 13.

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

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

Constraints
  • 2 ≤ len(lists) ≤ 100
  • 1 ≤ len(lists[i]) ≤ 100
  • 1 ≤ lists[i][j] ≤ 100
  • Each lists[i] is strictly increasing
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsMore Than a Third of the Votes MediumMost Common Values MediumJobs With a Cooldown MediumMost Searched Words MediumDomain Visit Rollup Medium
loading Python…
Input
lists=[[2, 5, 8, 13], [1, 2, 8, 9, 13], [2, 3, 8, 13, 20]]
Expected
[2, 8, 13]

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