FastPrepEmployee Subordinates
Problems/Employee Subordinates

Employee Subordinates

InMobi logoInMobi● EasyNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an InMobi new grad online assessment. The interview report names DoSelect as the place the test was hosted. It describes this question only as similar to the well-known employee subordinates exercise. Our version is about 88% the same as the reported question.

A company has n employees numbered from 1 through n. Employee 1 is the general director.

The array bosses has length n - 1. For each index i, bosses[i] is the direct boss of employee i + 2.

Return an array subordinateCounts of length n, where subordinateCounts[i] is the number of direct and indirect subordinates of employee i + 1.

Function

countSubordinates(bosses: int[]) → int[]

Examples

Example 1

bosses = [1,1,2,3]return = [4,1,1,0,0]

Employee 1 has all four other employees as subordinates. Employees 2 and 3 each have one subordinate, while employees 4 and 5 have none.

Example 2

bosses = [1,2,3,4]return = [4,3,2,1,0]

The hierarchy is one chain: employee 1 manages employee 2, who manages employee 3, and so on. Each employee's subordinates are everyone further down the chain. So each count is one less than the count before it, and the last employee has none.

Example 3

bosses = []return = [0]

There is only the general director, so no employee has a subordinate.

Constraints

  • 1 <= bosses.length + 1 <= 2 * 10^5
  • 1 <= bosses[i] <= bosses.length + 1
  • In bosses, following the boss links upward from any employee always ends at employee 1, the general director.

More InMobi Online Assessment questions

  • Validate a Bracket SequenceOA · Seen Oct 2026
  • Count Substrings Matching with One Adjacent SwapOA · Seen Oct 2026
  • Maximum Subarray with Start and End WindowsOA · Seen Oct 2026
  • Minimum Service Cold StartsOA · Seen Oct 2026
  • Range Maximum Subarray Sum QueriesOA · Seen Oct 2026
  • Connected Components with Divisor ThresholdOA · Seen Aug 2026
  • Maximize Impression ValueOA · Seen Aug 2026
  • Supply Path OptimizationOA · Seen Aug 2026
  • Delivery ServiceOA · Seen Jun 2026
  • Shared InterestOA · Seen Jun 2026

Similar questions at other companies

  • Count Parent Nodes With a Target SumAdobe · OAAdobe interview questions
  • Max Minus Min Weight in Every SubtreeHudson River Trading · OAHudson River Trading interview questions
  • Leaf-Similar TreesAtlassian · OAAtlassian interview questions
  • Preorder, Inorder and Postorder of a Binary TreeCapital One · OA · ONSITE INTERVIEWCapital One interview questions
  • Minimum Leaf Path Sum over All RootsInfosys · OAInfosys interview questions
  • Count Prime Values in SubtreesVisa · OAVisa interview questions
  • Palindromic Paths to the RootRippling · OARippling interview questions
  • Part 2: Batch Access ReviewScale AI · OAScale AI interview questions
  • Sum Dynamic Weighted Tree DistancesJuspay · OA
  • Sewer Drainage PartitionTwo Sigma · OATwo Sigma interview questions
All InMobi interview questionsSee InMobi hiring insights
Saved
class Solution {
    public int[] countSubordinates(int[] bosses) {
      // write your code here.
    }
}
Checking account…