FastPrepTeam-Preferred Stable Matching
Problems/Team-Preferred Stable Matching

Team-Preferred Stable Matching

Bloomberg LP logoBloomberg LP● HardNEW GRADONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report gives rankings in both directions between teams and employees. It says team preference wins when matches conflict, and it shows a result for two teams. We turned that into a one-to-one matching with the same number of teams and employees, where teams propose, as in Gale-Shapley. Each team takes one employee and every ranking is complete. These are rules we chose, and they make the answer fixed.

There are n teams and n new employees. Each team has one open position, and each employee joins exactly one team.

  • teamPreferences[t] lists every employee index, from the one team t likes most to the one it likes least.
  • employeePreferences[e] lists every team index, from the one employee e likes most to the one they like least.

A matching is stable when no team and employee would both rather be with each other. Put another way, there is no unmatched pair (t, e) where team t prefers employee e over its own employee, and employee e also prefers team t over their own team.

There can be more than one stable matching. Teams get priority, so return the team-optimal one: the stable matching you get when teams propose, as in the Gale-Shapley process. Each team proposes to employees in its preference order. Each employee keeps the best team that has proposed so far and turns the others down.

Return an array assignment where assignment[t] is the employee matched to team t.

Function

teamPreferredMatching(teamPreferences: int[][], employeePreferences: int[][]) → int[]

Examples

Example 1

teamPreferences = [[0,1],[0,1]]employeePreferences = [[0,1],[1,0]]return = [0,1]

Both teams first propose to employee 0. Employee 0 prefers team 0 and keeps it. Team 1 then proposes to employee 1, who accepts. That gives the answer.

Example 2

teamPreferences = [[0,1,2],[1,0,2],[1,2,0]]employeePreferences = [[1,0,2],[0,2,1],[2,1,0]]return = [1,0,2]

One rejection leads to the next. Employee 1 first holds team 1, then trades up to team 2, and then to team 0. Employee 0 trades up from team 0 to team 1. Team 2 is left with employee 2, which gives the answer.

Example 3

teamPreferences = [[0]]employeePreferences = [[0]]return = [0]

The only team and employee must be matched.

Constraints

  • 1 <= n == teamPreferences.length == employeePreferences.length <= 1000.
  • Every row in both matrices has length n.
  • Every team-preference row is a permutation of employee indices 0..n-1.
  • Every employee-preference row is a permutation of team indices 0..n-1.

More Bloomberg LP Onsite Interview questions

  • Collatz Conjecture with Shared MemoizationPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Word SearchOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Top K Frequent WordsONSITE INTERVIEW · Seen Nov 2026
  • Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Mutable Stock Price Top KPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Add Two Numbers IIPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Decode StringPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Minimum Replacements to Make Two Strings AnagramsPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026

Similar questions at other companies

  • Ring Buffer OperationsAmazon · ONSITE INTERVIEW
  • Five-Minute Hit CounterGoogle · ONSITE INTERVIEWGoogle interview questions
  • Sliding-Window Rate LimiterSnowflake · ONSITE INTERVIEWSnowflake interview questions
  • Recent Hit CounterAmazon Web Services · ONSITE INTERVIEWAmazon Web Services interview questions
  • Bounded Token-Bucket Request QueuePlaid · ONSITE INTERVIEWPlaid interview questions
  • Streaming Ingredient DishesHarness · ONSITE INTERVIEW
  • Paginate Provider Listings with Per-Page DiversityMaven Clinic · ONSITE INTERVIEWMaven Clinic interview questions
  • Evaluate a Blackjack HandGoldman Sachs · ONSITE INTERVIEWGoldman Sachs interview questions
  • Simulate Multiplayer WarPalantir · ONSITE INTERVIEWPalantir interview questions
  • Total Stops of an Elevator Serving a QueueExpedia · ONSITE INTERVIEWExpedia interview questions

Bloomberg LP interview experiences

  • Bloomberg AI-Assisted Coding Round, All Levels: 14 Experiences
  • Bloomberg SWE Intern Interview Questions: 68 Questions
  • Bloomberg Interview Questions, Level Not Reported: 65 Questions
  • Bloomberg Experienced Design & More: 126 Questions (Part 2 of 2)
  • Bloomberg Experienced SWE Interviews: 167 Questions (Part 1 of 2)
  • Bloomberg New Grad Coding Questions: 121 Questions (Part 2 of 2)
All Bloomberg LP interview questionsSee Bloomberg LP hiring insights
Saved
class Solution {
    public int[] teamPreferredMatching(int[][] teamPreferences, int[][] employeePreferences) {
        // Write your code here.
    }

}
Checking account…