Intersection of Two Lists
Updated
Problem statement
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 <= 10000 <= 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
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)