Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Find Matching Elements in Arrays

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

Your question is Find Matching Elements in Arrays. 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

LiveRamp audience workflows may receive multiple lists of identifiers from different activation sources. Given a list of integer arrays, return the unique identifiers that appear in every array.

The output must preserve the order in which identifiers first appear in the first array. Duplicate occurrences within any input array count only once.

Formal Specification

Implement matching_elements(arrays).

  • Input: arrays, a non-empty list of integer arrays.
  • Output: A list of unique integers present in every input array, ordered by their first appearance in arrays[0].
  • If no identifier is common to all arrays, return an empty list.

Constraints

  • 1 <= len(arrays) <= 10^4
  • 0 <= len(arrays[i]) <= 10^4
  • The total number of input elements is at most 10^5
  • -10^9 <= arrays[i][j] <= 10^9
  • Duplicate identifiers within an array count only once

Function Signature

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