FastPrepIntersection of Two Lists
Problems/Intersection of Two Lists

Intersection of Two Lists

LinkedIn logoLinkedIn● EasyINTERNPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A firsthand LinkedIn phone screen report for an intern role gave only the words two lists intersection. The author said it looked like a practice-site task. Here, you find the distinct integers that appear in both lists and return them sorted. We chose how to treat repeats, the order, the limits and the function name. Our version is about 80% the same as the reported question.

Special thanks: And another big thank you to the best Rachel~ 🌷

Given two integer lists listA and listB, return their set intersection: every distinct integer that occurs in both inputs.

Each common value must appear exactly once in the result. Return the values in increasing order so that the output is deterministic.

Function

intersectLists(listA: int[], listB: int[]) → int[]

Examples

Example 1

listA = [1,2,2,1]listB = [2,2]return = [2]

The only distinct value present in both lists is 2.

Example 2

listA = [4,9,5]listB = [9,4,9,8,4]return = [4,9]

4 and 9 occur in both inputs and are returned once each in increasing order.

Example 3

listA = []listB = [1,2,3]return = []

An empty list has no values in common with the other list.

Constraints

  • 0 <= listA.length, listB.length <= 200000
  • -10^9 <= listA[i], listB[i] <= 10^9
  • The returned values must be unique and sorted in increasing order.

More LinkedIn Phone Screen questions

  • Total Years of Work ExperiencePHONE SCREEN · Seen Nov 2026
  • Sum an Arbitrary-Dimensional ArrayPHONE SCREEN · Seen Oct 2026
  • Known Words Matching Phone DigitsPHONE SCREEN · Seen Oct 2026
  • Inverse-Depth Nested List SumPHONE SCREEN · Seen Oct 2026
  • Valid Number with ExponentsPHONE SCREEN · Seen Oct 2026
  • Maximum Product of a Contiguous SubarrayPHONE SCREEN · Seen Oct 2026
  • Maximum Sum of a Contiguous SubarrayPHONE SCREEN · Seen Oct 2026
  • Sort a Quadratic-Transformed ArrayPHONE SCREEN · Seen Oct 2026
  • Constant-Time Minimum StackPHONE SCREEN · Seen Oct 2026
  • Randomized String MultisetPHONE SCREEN · Seen Oct 2026

Similar questions at other companies

  • Majority ElementByteDance · PHONE SCREENByteDance interview questions
  • Recommend Films from Viewers Who Watched Everything You DidBloomberg LP · PHONE SCREENBloomberg LP interview questions
  • Shared Courses for Every Pair of StudentsCrunchyroll · PHONE SCREENCrunchyroll interview questions
  • Employee Count Median, Mean and ModeClay · PHONE SCREEN
  • Convert an Entry List to a MapEPAM · PHONE SCREENEPAM interview questions
  • Values Exclusive to the Current UserMeta · PHONE SCREENMeta interview questions
  • Count Values Appearing Exactly OnceAgoda · PHONE SCREENAgoda interview questions
  • Top Two Users by Total Purchase AmountSnowflake · PHONE SCREENSnowflake interview questions
  • Restaurant Vote LeadersZipRecruiter · PHONE SCREEN · ONSITE INTERVIEWZipRecruiter interview questions
  • AI Role: Collection with Add and Remove OperationsApple · PHONE SCREENApple interview questions

Interview reports that mention this question

  • Google, Datadog, LinkedIn SWE Intern Onsites: 1 Experience

LinkedIn interview experiences

  • LinkedIn Staff AI Engineer Phone Screens: 1 Experience
  • LinkedIn Experienced MLE Onsite: 1 Experience
  • LinkedIn Coding with AI Interview: 4 Experiences
  • LinkedIn Experienced Infrastructure SWE Onsite: 1 Experience
All LinkedIn interview questionsSee LinkedIn hiring insights
Saved
class Solution {
    public int[] intersectLists(int[] listA, int[] listB) {
      // Write your code here.
    }
}
Checking account…