You are given a two-dimensional array nums of positive integers. Every inner array contains a set of distinct values (no duplicates within a single inner array).
Return a sorted list, in ascending order, of the integers that appear in every inner array of nums.
If no integer is present in all of the inner arrays, return an empty list.
Example 1
Input: nums = [[3,1,2,4,5],[1,2,3,4],[3,4,5,6]]
Output: [3,4]
Only 3 and 4 appear in all three inner arrays, so the sorted intersection is [3,4].
Example 2
Input: nums = [[1,2,3],[4,5,6]]
Output: []
No value is shared between the two inner arrays, so the result is empty.
Constraints
1 <= nums.length <= 10001 <= sum(nums[i].length) <= 10001 <= nums[i][j] <= 1000All values within each nums[i] are distinctSee the step-by-step animation, the intuition, and clean code in every language — free, no credit card.
FDE Coach is a cohort-based program in frontend, backend, AWS, and AI where you build real products and get referred to 200+ hiring partners. The free live workshop is the fastest way to see how we teach.
750+ engineers trained · frontend, backend, AWS & AI