Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Sorted Arrays Intersection

MediumPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Sorted Arrays Intersection. Start with the requirements on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

An Airtable automation compares sorted record-ID lists from multiple Airtable views. Given a list of sorted integer arrays, return the distinct values that appear in every array, in ascending order.

Formal Specification

Implement intersect_sorted_arrays(arrays), where arrays is a list of arrays of integers. Each inner array is sorted in nondecreasing order and may contain duplicates. Return a new sorted list containing each common value exactly once. If arrays is empty, return an empty list. If any inner array is empty, no value can appear in all arrays, so return an empty list.

Constraints

  • 0 <= len(arrays) <= 10^4
  • The total number of elements across all arrays is at most 10^6
  • Each inner array is sorted in nondecreasing order
  • Values are integers in the range -10^9 to 10^9
  • The result contains each common value exactly once

Function Signature

def intersect_sorted_arrays(arrays):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output