FastPrepEmployee Importance from a Dictionary
Problems/Employee Importance from a Dictionary

Employee Importance from a Dictionary

Patreon logoPatreon● MediumFULLTIMEPHONE SCREEN

Updated Dec 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Patreon coding interview by a mid-level software engineer, posted in February 2026. The task was the well-known employee importance problem: add up the importance of one employee and of everyone below them in the reporting chain. The twist was that the employee data came as a dictionary rather than as employee objects. The report does not say which round this was, so we list it as a phone screen.

The report does not say how the dictionary is laid out. Here, it is keyed by employee id, and each entry holds that person's importance and the ids of their direct reports. Your function gets the dictionary as a list of its entries, one row per employee, in any order. The report gives no limits or examples, so the examples and the limits are ours: up to 400 employees, ids from 1 to 2,000, importance from -100 to 100, at most one direct manager per person, and no loops in the chain.

Our version is about 85% the same as the reported question.

Given the employee records employees of a company and an employee id id, return the total importance of that employee plus every person who reports to them, directly or indirectly.

The records are a dictionary keyed by employee id, given as a list of its entries. Each entry is one row employees[i] = [eid, importance, r1, r2, ...]: employee eid has the importance value importance, and r1, r2, ... are the ids of the people whose direct manager is eid. A row with only two numbers belongs to someone with no direct reports. The rows can come in any order.

A person reports to id indirectly when id is their manager's manager, or further up the same chain.

Function

getImportance(employees: List<List<Integer>>, id: int) → int

Examples

Example 1

employees = [[3, 4, 7], [1, 10, 3, 5], [5, -2], [7, 6], [9, 8]]id = 1return = 18

Employees 3 and 5 report directly to employee 1, and employee 7 reports to 3, so 7 is an indirect report. Employee 9 is not in this chain, so the total is 10 + 4 + (-2) + 6 = 18.

Example 2

employees = [[3, 4, 7], [1, 10, 3, 5], [5, -2], [7, 6], [9, 8]]id = 3return = 10

Only employee 7 is below employee 3, so the total is 4 + 6 = 10. Employees 1 and 5 are not below 3, so they are left out.

Example 3

employees = [[2, -5], [4, 3, 2]]id = 2return = -5

Nobody reports to employee 2, so the answer is their own importance, -5. Employee 4 is their manager and is not counted.

Constraints

  • 1 <= employees.length <= 400
  • 2 <= employees[i].length
  • 1 <= employees[i][0] <= 2000, and no two rows have the same employee id.
  • -100 <= employees[i][1] <= 100
  • Every report id employees[i][j] with j >= 2 is the id of another row, and it appears at most once in that row.
  • Every employee has at most one direct manager, and no one is their own manager through any chain.
  • id is the id of one of the rows.

More Patreon Phone Screen questions

  • Sliding-Window API Rate LimiterPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Uniform Random Number from Coin TossesPHONE SCREEN · Seen Feb 2026
  • Wordle Guess CheckerPHONE SCREEN · Seen Jan 2026
  • Org Chart Report CountsPHONE SCREEN · Seen Dec 2025
  • Format the Missing Numbers from 1 to 99PHONE SCREEN · Seen Sep 2025
  • Pythagorean Triplets in an ArrayPHONE SCREEN · Seen Oct 2024
  • LRU Cache with TTLPHONE SCREEN · ONSITE INTERVIEW · Seen Jun 2022
  • Password GeneratorPHONE SCREEN · ONSITE INTERVIEW · Seen Mar 2022
  • Merge IntervalsPHONE SCREEN · ONSITE INTERVIEW · Seen Feb 2022
  • JSON ParserPHONE SCREEN · Seen Jun 2021

Similar questions at other companies

  • Transform and Prune a Mode-Valued Binary TreeGoogle · PHONE SCREENGoogle interview questions
  • Team Cost Under a ManagerRippling · PHONE SCREENRippling interview questions
  • Top View of a Binary TreeInMobi · ONSITE INTERVIEWInMobi interview questions
  • N-ary Index-Path Encoder and DecoderBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Account Roles With Parent-User InheritanceStripe · PHONE SCREENStripe interview questions
  • Find All Paths for a Name in a File SystemThe Walt Disney Company · PHONE SCREENThe Walt Disney Company interview questions
  • Validate a BST with a Custom ComparisonApple · PHONE SCREENApple interview questions
  • Tree Height After Child PromotionSnowflake · PHONE SCREENSnowflake interview questions
  • Binary Tree Spiral Level OrderAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Check a Complete Binary TreeGoldman Sachs · PHONE SCREENGoldman Sachs interview questions
All Patreon interview questionsSee Patreon hiring insights
Saved
class Solution {
    public int getImportance(List<List<Integer>> employees, int id) {
        // Write your code here.
    }
}
Checking account…