FastPrepOrg Chart Report Counts
Problems/Org Chart Report Counts

Org Chart Report Counts

Patreon logoPatreon● EasyFULLTIMEPHONE SCREEN

Updated Dec 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported at Patreon by seven candidates in 2024 and 2025: three Software Engineers who give no level and four who give no role.

A July 2024 post titled as a phone screen shows the chart as a nested map: each manager maps to the people under them, and a person with no reports maps to null. A lookup by name returns manager plus how many people report to the person directly and in all, or IC,0,0. It asks whether to precompute the counts or walk the chart on each lookup; its follow-ups add an IC under an employee and keep both counts right for everyone above. Comments from July, November and December 2025 report the same task.

Software Engineer reports from March, October and December 2024 describe this task in one technical interview; in October and December it came after a recruiter call. In March and December it was a 50-minute online coding session with an interviewer, a sample input with its output, and no prewritten code. The March candidate was not told how to treat non-positive cases, and the December candidate got no guidance on edge cases; the December tip suggests asking about cycles, empty input and non-positive numbers. The March report shows the chart as nested Python dictionaries keyed by the most senior people and wants a tuple of the word manager with both counts, or ('IC', 0, 0). The October report gives the chart as a dictionary and asks about report counts. The December report gives a month, not a day.

The July 2024 post names a phone screen; the 2024 Software Engineer reports give one technical interview with no later round, so we list it as a phone screen too. The comments name no round.

Our choices: one row per person (a name, then its direct reports) in place of nested dictionaries; a string answer as in the July 2024 post; 1 to 500 people with distinct names of 1 to 20 letters or digits, forming valid trees and containing the name looked up. The follow-ups are discussed, not tested.

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

A company's org chart is written as a nested dictionary. Its top-level keys are the people at the top of the company. Each person maps to a dictionary of the people who report directly to them, in the same format, or to null when no one reports to them.

In this problem the chart is passed as orgChart, with one row per person. A row starts with a person's name and then lists that person's direct reports. A person with no direct reports has a row that holds only their name. The rows can come in any order.

A person with at least one direct report is a manager. A person with no direct reports is an individual contributor, or IC. A person's total reports are everyone below them in the chart: their direct reports, the direct reports of those people, and so on down.

Given the name empName, return "IC,0,0" if that person is an IC. If the person is a manager, return "manager,d,t", where d is their number of direct reports and t is their number of total reports.

Follow-up: if the chart stays the same and you are asked about many people, would you count again on every call or work out all the counts once? And if a new IC can be added under any existing person, how do you keep the direct and total counts right for everyone above the new IC?

Function

lookup(orgChart: List<List<String>>, empName: String) → String

Examples

Example 1

orgChart = [["a","a1","a2"],["a1","a11","a12"],["a11"],["a12"],["a2"],["b"]]empName = "a"return = "manager,2,4"

As a nested dictionary, this chart is {"a": {"a1": {"a11": null, "a12": null}, "a2": null}, "b": null}. The people a1 and a2 report directly to a, and a11 and a12 report to a1. So a has 2 direct reports and 4 total reports.

Example 2

orgChart = [["Person1","Person2","Person3"],["Person2"],["Person3","Person4"],["Person4","Person5"],["Person5"]]empName = "Person3"return = "manager,1,2"

Only Person4 reports directly to Person3, and Person5 reports to Person4. That gives Person3 1 direct report and 2 total reports.

Example 3

orgChart = [["a","a1","a2"],["a1","a11","a12"],["a11"],["a12"],["a2"],["b"]]empName = "b"return = "IC,0,0"

The person b is at the top of the chart, but no one reports to b, so b is an IC.

Constraints

  • 1 <= orgChart.length <= 500
  • 1 <= orgChart[i].length <= 500
  • 1 <= orgChart[i][j].length <= 20
  • Every name is made of English letters and digits.
  • Every person has exactly one row: the first names of the rows are all different, and every name in orgChart is the first name of some row.
  • Each person is listed as a direct report in at most one row, and no person is below themselves in the chart.
  • empName is the first name of one of the rows.

More Patreon Phone Screen questions

  • Sliding-Window API Rate LimiterPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Employee Importance from a DictionaryPHONE SCREEN · Seen Feb 2026
  • Uniform Random Number from Coin TossesPHONE SCREEN · Seen Feb 2026
  • Wordle Guess CheckerPHONE SCREEN · Seen Jan 2026
  • 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

  • Mode of a Ternary Search TreeGoogle · PHONE SCREENGoogle 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
  • Validate a BST with a Custom ComparisonApple · PHONE SCREENApple interview questions
  • Count Distinct Rooted-Tree GraftsThe D.E. Shaw Group · PHONE SCREENThe D.E. Shaw Group interview questions
  • Lowest Common Manager for Employee GroupsAmazon · PHONE SCREEN
  • Merge N-Ary Trees by KeyLinkedIn · PHONE SCREEN · ONSITE INTERVIEWLinkedIn interview questions
  • Filesystem Hash TreeCursor · PHONE SCREEN · ONSITE INTERVIEWCursor interview questions
  • Render a Stable Comment HierarchyBobyard · PHONE SCREEN
  • Translate Values in a Nested MapZip · PHONE SCREENZip interview questions
All Patreon interview questionsSee Patreon hiring insights
Saved
class Solution {
    public String lookup(List<List<String>> orgChart, String empName) {
        // Write your code here.
    }
}
Checking account…