FastPrepIntersection of Two Lists
Problems/Intersection of Two Lists

Intersection of Two Lists

JP Morgan Chase logoJP Morgan Chase● EasyINTERNONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a JP Morgan Chase intern onsite interview. The report asks for list intersection. It does not say whether the lists share values or linked nodes, or what to do about duplicates or order. This version uses distinct shared values in sorted order. Our version is about 80% the same as the reported question.

Return the distinct integer values that occur in both first and second, in increasing numeric order.

The inputs represent lists of values. Repeated values appear once in the result. If there are no common values, return an empty array.

Function

intersection(first: int[], second: int[]) → int[]

Examples

Example 1

first = [1,2,2,1]second = [2,2]return = [2]

The only shared value is 2; duplicates are emitted once.

Example 2

first = [4,9,5]second = [9,4,9,8,4]return = [4,9]

The distinct shared values are 4 and 9, returned in increasing order.

Constraints

  • 0 <= first.length <= 1000
  • 0 <= second.length <= 1000
  • -10^6 <= first[i], second[i] <= 10^6

More JP Morgan Chase Onsite Interview questions

  • LFU CacheONSITE INTERVIEW · Seen Nov 2026
  • LRU CacheONSITE INTERVIEW · Seen Nov 2026
  • Employees Above Average SalaryONSITE INTERVIEW · Seen Sep 2026
  • Highest-Earning Employees By DepartmentONSITE INTERVIEW · Seen Sep 2026
  • K Largest Integers in Descending OrderONSITE INTERVIEW · Seen Aug 2026
  • Tile a Three-Row Board with DominoesONSITE INTERVIEW · Seen Jan 2026
  • Two SumONSITE INTERVIEW · Seen Nov 2025
  • Maximum Subarray SumONSITE INTERVIEW · Seen Jan 2025
  • Fibonacci NumberONSITE INTERVIEW · Seen Nov 2024
  • Integrate a Sampled FunctionONSITE INTERVIEW · Seen Nov 2024

Similar questions at other companies

  • Map and Accumulate Learning QueriesPalantir · ONSITE INTERVIEWPalantir interview questions
  • Filter Anagrams of a TargetMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Rank Transform an ArrayAgoda · ONSITE INTERVIEWAgoda interview questions
  • Deduplicate Logs: Keep FirstGoogle · ONSITE INTERVIEWGoogle interview questions
  • Loyal Customers by Two-Day Product VarietyAmazon · ONSITE INTERVIEW
  • Restaurant Vote LeadersZipRecruiter · PHONE SCREEN · ONSITE INTERVIEWZipRecruiter interview questions
  • High-Severity Counts by Search TypeChainalysis · ONSITE INTERVIEWChainalysis interview questions
  • Pair Left and Right Socks by IDRoblox · ONSITE INTERVIEWRoblox interview questions
  • Net Position Calculation from API SnapshotsHeadlands Technologies · ONSITE INTERVIEWHeadlands Technologies interview questions
  • Count Word FrequenciesBloomberg LP · ONSITE INTERVIEWBloomberg LP interview questions

Interview reports that mention this question

  • JPMorgan Tech Intern Interviews: 43 Experiences (Part 1 of 5)

JP Morgan Chase interview experiences

  • JPMorgan Quant Stats Superdays: 3 Experiences (Part 3 of 3)
  • JPMorgan Quant Modeling Superdays: 7 Experiences (Part 2 of 3)
  • JPMorgan Quant Intern Superday: 19 Experiences (Part 1 of 3)
  • JP Morgan Chase Data and AI Intern Superday: 11 Experiences
  • JPMorgan Code for Good India 2024: 6 Experiences (Part 5 of 5)
All JP Morgan Chase interview questionsSee JP Morgan Chase hiring insights
Saved
class Solution {
    public int[] intersection(int[] first, int[] second) {
        // Write your code here.
    }
}
Checking account…