FastPrepOffice Employee Hierarchy
Problems/Office Employee Hierarchy

Office Employee Hierarchy

Bloomberg LP logoBloomberg LP● MediumINTERNPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A report from a Bloomberg student software engineer interview in Tel Aviv in November 2024 describes one long practical task, done over a video call in a language of the candidate's choice by filling in a given code template. The task models an office: each person has an ID and a boss who is a person of the same kind, and the office keeps a head and a headcount. The candidate had to support four actions: hiring a person, showing who reports to whom, giving a person a new boss, and removing a person. The report gives no output format, limits or example.

Everything else here is our practice choice. The work is a list of operations, and only print produces output. A printed hierarchy is an ID followed by its direct reports in parentheses, in increasing ID order. When a person is removed, their direct reports move up to the boss that person had, and a person who gets a new boss keeps their own reports. Every operation is valid, the head never moves or leaves, the office never has more than 200 people, there are at most 1,000 operations, IDs are from 1 to 10,000, and the employee count is not judged.

The judged task matches the report at about 70%.

An office has a head and employees. Every person has a different integer ID. Everyone except the head reports to exactly one manager, who is also in the office. At the start, the office holds only the head, whose ID is headId.

You are given a list of operations. Operation operations[i] uses the numbers in args[i]:

  • "add" with [id, managerId]: a new employee id joins and reports to managerId. The ID id is not in the office at that moment, and managerId is.
  • "changeManager" with [id, managerId]: employee id now reports to managerId. The people who report to id keep reporting to id, so they move along. Here id is in the office and is not the head, and managerId is in the office and is neither id nor anyone below id.
  • "delete" with [id]: employee id leaves. The people who reported directly to id now report to the manager id had. Here id is in the office and is not the head.
  • "print" with []: record the current hierarchy as a string.

The string for a person is their ID. If they have direct reports, it is followed by the strings of those reports in parentheses, separated by commas, in increasing ID order. A person with no reports has no parentheses. For example, "1(2(4),3)" means that 2 and 3 report to 1 and 4 reports to 2. The hierarchy string is the string of the head.

Return the strings recorded by the "print" operations, in order.

Function

manageOffice(headId: int, operations: String[], args: int[][]) → List<String>

Examples

Example 1

headId = 1operations = ["add","add","add","print","changeManager","print","delete","print"]args = [[2,1],[3,1],[4,2],[],[4,3],[],[3],[]]return = ["1(2(4),3)","1(2,3(4))","1(2,4)"]

After the three adds, 2 and 3 report to the head 1, and 4 reports to 2. The first print is "1(2(4),3)".

Then 4 moves to manager 3, so the second print is "1(2,3(4))". Deleting 3 moves its report 4 up to 3's manager, the head 1. The last print is "1(2,4)".

Example 2

headId = 10operations = ["add","add","add","print"]args = [[11,10],[9,10],[2,9],[]]return = ["10(9(2),11)"]

11 and 9 report to 10, and 2 reports to 9. Reports are listed by increasing ID as numbers, so 9 comes before 11. The print is "10(9(2),11)".

Example 3

headId = 5operations = ["add","add","add","delete","print"]args = [[7,5],[8,7],[6,7],[7],[]]return = ["5(6,8)"]

7 reports to 5, and 8 and 6 report to 7. When 7 is deleted, 8 and 6 move up to 7's manager, 5. The print is "5(6,8)".

Constraints

  • 1 <= operations.length <= 1000 and args.length == operations.length
  • 1 <= headId, args[i][j] <= 10000
  • args[i].length is 2 for "add" and "changeManager", 1 for "delete" and 0 for "print".
  • Every operation is valid as described above, and operations contains at least one "print".
  • The office never has more than 200 people, the head included.

More Bloomberg LP Phone Screen questions

  • N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Word SearchOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Fewest Coins CombinationPHONE SCREEN · Seen Nov 2026
  • Recommend Films from Viewers Who Watched Everything You DidPHONE SCREEN · Seen Nov 2026
  • Track New Values in Sorted OrderPHONE SCREEN · Seen Nov 2026
  • Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Mutable Stock Price Top KPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Sparse Vector and Matrix OperationsPHONE SCREEN · Seen Oct 2026
  • Add Two Numbers IIPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026

Similar questions at other companies

  • In-Memory Filesystem CommandsPerplexity AI · PHONE SCREEN · ONSITE INTERVIEWPerplexity AI interview questions
  • Workspace File System With Folders and TablesClay · PHONE SCREEN
  • In-Memory File System With Directory SizesCapital One · PHONE SCREEN · ONSITE INTERVIEWCapital One interview questions
  • LRU Cache for Query ResultsAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Tree Selection and VisibilityJane Street · PHONE SCREENJane Street interview questions
  • Rectangle Point Coverage CountsOpenAI · PHONE SCREEN · ONSITE INTERVIEWOpenAI interview questions
  • File Storage ServiceCresta · PHONE SCREENCresta interview questions
  • Worst-Performing Ads by CTR in a Campaign TreeUber · PHONE SCREENUber interview questions
  • Camel CardsRippling · PHONE SCREEN · ONSITE INTERVIEWRippling interview questions
  • Return Every Matching DecryptionDuolingo · PHONE SCREENDuolingo interview questions

Bloomberg LP interview experiences

  • Bloomberg SWE Phone Screen and Onsite: 1 Experience
  • Bloomberg SWE Phone Screens with Two Teams: 1 Experience
  • Bloomberg AI Interview, Hiring Level Not Reported: 2 Experiences
  • Bloomberg Experienced SWE AI Coding Interviews: 2 Experiences
  • Bloomberg New Grad AI-Assisted Coding Rounds: 3 Experiences
  • Bloomberg New Grad SWE AI-Assisted Coding Rounds: 1 Experience
All Bloomberg LP interview questionsSee Bloomberg LP hiring insights
Saved
class Solution {
    public List<String> manageOffice(int headId, String[] operations, int[][] args) {
        // Write your code here.
    }
}
Checking account…