FastPrepAnalyze Underpaid Managers in a Salary Tree
Problems/Analyze Underpaid Managers in a Salary Tree

Analyze Underpaid Managers in a Salary Tree

Google logoGoogle● HardNEW GRADPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report asks for counts of underpaid managers, measured by the mean and the median of their descendants, plus the smallest total budget to fix it. We made it explicit that raises are integers, how the median works for an even count, and how raising a manager affects the managers above. Our version is about 89% the same as the reported question.

A company hierarchy is a rooted tree. parent[i] is the direct manager of employee i, or -1 for the root. salary[i] is the employee's positive integer salary.

For every manager with at least one direct or indirect report, compare the manager's salary with all direct and indirect reports:

  1. Count managers whose salary is strictly below the average of their reports' original salaries.
  2. Compute the minimum total integer salary increase needed so that no manager is below the average of all direct and indirect reports' final salaries. Salaries may only increase. Leaves remain unchanged.
  3. Count managers whose salary is strictly below the median of their descendants' original salaries. For an even descendant count, the median is the average of the two middle values.

Return these three results as [meanCount, minimumBudget, medianCount].

Function

analyzeManagerSalaries(parent: int[], salary: int[]) → long[]

Examples

Example 1

parent = [-1,0,0]salary = [50,60,80]return = [1,20,1]

The root's descendant mean and median are both 70, so it needs a raise from 50 to 70.

Example 2

parent = [-1,0,1,1]salary = [10,10,30,50]return = [2,60,2]

Manager 1 rises from 10 to 40. The root's final descendants are then 40, 30, and 50, so the root also rises from 10 to 40. The total budget is 60.

Example 3

parent = [-1,0,0,1]salary = [100,80,60,40]return = [0,0,0]

No manager is below either descendant statistic, and no raise is needed.

Constraints

  • 1 <= parent.length = salary.length <= 200.
  • Exactly one entry of parent is -1; all other entries form one rooted tree.
  • 1 <= salary[i] <= 10^9.
  • The final budget fits a signed 64-bit integer.

More Google Phone Screen questions

  • Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Periodic-Color Binary Forest RootsPHONE SCREEN · Seen Nov 2026
  • Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Best Stock Trade with Buy and Sell DaysPHONE SCREEN · Seen Nov 2026
  • Word Chain Jumps in a GridPHONE SCREEN · Seen Nov 2026
  • Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Apartment Housemate PreferencesPHONE SCREEN · Seen Nov 2026
  • Price at Query TimestampsPHONE SCREEN · Seen Nov 2026
  • Course Schedule Cycle DetectionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Recursive Display SortFigma · PHONE SCREEN · ONSITE INTERVIEWFigma interview questions
  • Lowest Common Manager for Employee GroupsAmazon · PHONE SCREEN
  • File Encryption Tree OptimizationDatabricks · PHONE SCREEN · ONSITE INTERVIEWDatabricks interview questions
  • Vertical Order Traversal of a Binary TreeBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Vertical Tree Traversal with Value TiesMeta · PHONE SCREENMeta interview questions
  • Maximum Path Sum Between Marked NodesDoorDash · PHONE SCREENDoorDash interview questions
  • House Robber IIIOkta · PHONE SCREENOkta interview questions
  • House Robber IIIGoldman Sachs · PHONE SCREENGoldman Sachs interview questions
  • House Robber IIIVisa · PHONE SCREENVisa interview questions
  • Find All Paths for a Name in a File SystemThe Walt Disney Company · PHONE SCREENThe Walt Disney Company interview questions

Google interview experiences

  • Google interviews · November 2026
  • Google Software Engineer Onsite Questions: 10 Experiences
  • Google OA: What It Tests (2026)
  • Google L4 SWE Phone Screen: 1 Experience
  • Google ML Engineering Manager Onsite: 1 Experience
  • Google Experienced SWE First Round and Onsite: 1 Experience
All Google interview questionsSee Google hiring insights
Saved
class Solution {
    public long[] analyzeManagerSalaries(int[] parent, int[] salary) {
        // Write your code here.
    }
}
Checking account…