Question bank › Recursion
Dsa Recursion Easy

The Executive Payroll

Given a company's organizational structure, calculate the total payroll (sum of salaries) for a specific manager and all of their direct and indirect subordinates. Every employee has exactly one manager, except for the CEO whose manager is 'None'. Input Format: 1. The name of the Manager to query. 2. An integer N, the total number of employees. 3. N lines, each containing: 'EmployeeName Salary ManagerName' Output Format: A single integer representing the total payroll for that branch of the tree. Example: Input: Alice 3 Alice 5000 None Bob 3000 Alice Charlie 2000 Alice Output: 10000

Key concepts

recursiontree traversalsummation

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.