FastPrepSet Intersection
Problems/Set Intersection

Set Intersection

BlackRock logoBlackRock● EasyINTERNOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a BlackRock intern online assessment. The report does not say how to handle duplicates, the numeric limits, or the function signature. We chose those. Our version is about 95% the same as the reported question.

You are given two integer arrays, first and second, each sorted in non-decreasing order.

Return their set intersection in ascending order. Every integer that appears in both arrays must appear exactly once in the result, even if it occurs multiple times in either input.

Function

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

Examples

Example 1

first = [1,2,3,4]second = [4,5,6]return = [4]

The only integer present in both arrays is 4.

Example 2

first = [-5,-1,0,3,7,10]second = [-8,-1,3,3,10,12]return = [-1,3,10]

The shared values are -1, 3, and 10. The repeated 3 in second contributes only one result value.

Example 3

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

Both arrays contain 1 and 5. Each shared value appears once in the set intersection.

Constraints

  • 1 ≤ first.length, second.length ≤ 10^5
  • -10^9 ≤ first[i], second[i] ≤ 10^9
  • first and second are sorted in non-decreasing order.
  • The returned array must contain no duplicate values.

More BlackRock interview questions

  • Find Minimum TimeOA · Seen Nov 2026
  • Count LevelsOA · Seen Sep 2026
  • Valid ParenthesesOA · Seen Sep 2026
  • Lowest Common Ancestor in a Parent TreeOA · Seen Sep 2026
  • Road Trip (Analyst Program :POA · Seen Aug 2026
  • John Venn (Analyst Program :)OA · Seen Sep 2024
  • Corporate LadderOA · Seen Jul 2024
  • Happy NumberOA · Seen Jul 2024
  • Process SchedulingPHONE SCREEN · Seen Mar 2026

Similar questions at other companies

  • Catch Fish with Reusable BaitsSusquehanna International Group (SIG) · OA
  • Minimum Index Distance Between Person and CakeSnowflake · OA · PHONE SCREEN
  • Meandering ArrayVerisk · OA
  • Interleave Array HalvesAutodesk · OA
  • Collect Branches for a Bird NestVisa · OA
  • Maximum Requests in a Time WindowIBM · OA
  • Can Every Package Fit in a BoxIMC Trading · OA
  • Filter Odds and Reverse EvensUpstart · OA
  • Score Difference When Even Picks Reverse the ListMicrosoft · OA
  • Maximum Events in a 60-Second WindowMarshall Wace · OA
See BlackRock hiring insights
Saved
class Solution {
    public int[] setIntersection(int[] first, int[] second) {
      // Write your code here
    }
}
Checking account…