FastPrepOrganization Chart by Level
Problems/Organization Chart by Level

Organization Chart by Level

Microsoft logoMicrosoft● EasyNEW GRADONSITE INTERVIEW

Updated Oct 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A Microsoft Data Scientist PhD internship report describes modeling an organization chart as a tree and showing each full layer top-down with BFS and a queue. The manager-array schema, employee ordering, return representation, and bounds are conventional enrichment.

An organization contains employees numbered from 0 through n - 1. The array manager describes a rooted tree: employee 0 is the root and has manager -1; for every other employee i, manager[i] is that employee's direct manager.

Return the complete organization chart one layer at a time from the root downward. Employees within each layer must appear in increasing employee-number order.

Function

organizationLevels(manager: int[]) → int[][]

Examples

Example 1

manager = [-1,0,0,1,1,2]return = [[0],[1,2],[3,4,5]]

Employee 0 is the root, employees 1 and 2 form the next layer, and their reports form the third.

Example 2

manager = [-1]return = [[0]]

A one-person organization has one layer.

Constraints

  • 1 <= manager.length <= 100000
  • manager[0] = -1
  • For 1 <= i < manager.length, 0 <= manager[i] < i

More Microsoft Onsite Interview questions

  • Bad Request AlertsONSITE INTERVIEW · Seen Nov 2026
  • Longest Substring Without Repeating CharactersONSITE INTERVIEW · Seen Nov 2026
  • Valid ParenthesesONSITE INTERVIEW · Seen Nov 2026
  • Count a User's Actions in an Event LogONSITE INTERVIEW · Seen Nov 2026
  • Smallest Batch Size Within a Step LimitONSITE INTERVIEW · Seen Nov 2026
  • Count Subarrays with Equal Even and Odd CountsONSITE INTERVIEW · Seen Nov 2026
  • Minimum Time to Rot All OrangesONSITE INTERVIEW · Seen Nov 2026
  • Coin ChangeONSITE INTERVIEW · Seen Oct 2026
  • Daily USD Totals with Effective-Dated Exchange RatesONSITE INTERVIEW · Seen Oct 2026
  • Number Words to Digits in Any LanguageONSITE INTERVIEW · Seen Oct 2026

Similar questions at other companies

  • Diameter of Binary TreeeBay · ONSITE INTERVIEWeBay interview questions
  • Maximum Depth of Binary TreeLinkedIn · PHONE SCREEN · ONSITE INTERVIEWLinkedIn interview questions
  • Binary Tree Level-Order Traversal by LevelsAdobe · PHONE SCREEN · ONSITE INTERVIEWAdobe interview questions
  • Check Whether All Leaves Are at the Same LevelAmazon · ONSITE INTERVIEW
  • Symmetric Binary TreeFigma · ONSITE INTERVIEWFigma interview questions
  • Tree Level with the Most NodesBloomberg LP · ONSITE INTERVIEWBloomberg LP interview questions
  • Mirror Image Binary TreesExpedia · ONSITE INTERVIEWExpedia interview questions
  • Mirror a Binary TreeAMD · ONSITE INTERVIEWAMD interview questions
  • Symmetric TreeZillow · ONSITE INTERVIEWZillow interview questions
  • Find a Node’s Level in an N-ary TreeMorgan Stanley · ONSITE INTERVIEWMorgan Stanley interview questions

Interview reports that mention this question

  • Microsoft AI/ML Intern Interviews: 114 Experiences (Part 1 of 2)

Microsoft interview experiences

  • Microsoft OA Questions, October 2026: 4 Experiences
  • Microsoft Experienced SWE Phone Screen: 1 Experience
  • Microsoft Explore and Student SWE: 12 Experiences (Part 6 of 6)
  • Microsoft SWE Intern, Early 2025: 41 Experiences (Part 5 of 6)
  • Microsoft SWE Intern, Mid 2025: 42 Experiences (Part 4 of 6)
All Microsoft interview questionsSee Microsoft hiring insights
Saved
class Solution {
    public int[][] organizationLevels(int[] manager) {
      // Write your code here.
    }

}
Checking account…