PracHub
QuestionsCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Uber

Kth Employee Reached in an Ordered Hierarchy

Last updated: Jul 17, 2026

Quick Overview

This tree-algorithms interview question evaluates practical understanding of ordered hierarchy traversal and repeated subtree selection queries. It is commonly used to assess traversal semantics, preprocessing judgment, scalability, and careful handling of indexing and out-of-range cases.

  • medium
  • Uber
  • Coding & Algorithms
  • Software Engineer

Kth Employee Reached in an Ordered Hierarchy

Company: Uber

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Take-home Project

# Kth Employee Reached in an Ordered Hierarchy Implement `kth_recipients(boss, queries)`. Employees are numbered `0` through `n - 1`. `boss[0] == -1`; for every other employee `i`, `boss[i]` is the direct manager of `i`, and the array forms one rooted tree. When data is sent to `start`, that employee receives it first. They then pass it recursively through their organization in depth-first preorder, visiting each employee's direct reports in ascending employee-number order. Each query is `(start, k)`, where `k` is one-indexed. Return the employee who is the `k`th recipient within `start`'s subtree, or `-1` if the subtree has fewer than `k` employees. ## Constraints - `1 <= n <= 200,000` - `1 <= len(queries) <= 200,000` - The hierarchy is a valid rooted tree. - Query starts are valid indices and `k >= 1`. ## Example behavior If employee `2` directly manages employees `4` and `7`, and `4` manages `5`, transmission from `2` visits `2, 4, 5, 7` before any later sibling subtree. ## Candidate clarifications Confirm whether the start employee counts as recipient one, whether traversal is depth-first, the sibling ordering, and out-of-range behavior.

Quick Answer: This tree-algorithms interview question evaluates practical understanding of ordered hierarchy traversal and repeated subtree selection queries. It is commonly used to assess traversal semantics, preprocessing judgment, scalability, and careful handling of indexing and out-of-range cases.

Related Interview Questions

  • Minimum Delivery Cost Between Cities - Uber (medium)
  • Last Truck to Leave a One-Dimensional Lane - Uber (medium)
  • Thread-Safe Token-Bucket Rate Limiter - Uber (medium)
  • Quadtree for 2D Geospatial Points - Uber (medium)
|Home/Coding & Algorithms/Uber

Kth Employee Reached in an Ordered Hierarchy

Uber logo
Uber
Jul 3, 2026, 12:00 AM
mediumSoftware EngineerTake-home ProjectCoding & Algorithms
2
0

Kth Employee Reached in an Ordered Hierarchy

Implement kth_recipients(boss, queries).

Employees are numbered 0 through n - 1. boss[0] == -1; for every other employee i, boss[i] is the direct manager of i, and the array forms one rooted tree.

When data is sent to start, that employee receives it first. They then pass it recursively through their organization in depth-first preorder, visiting each employee's direct reports in ascending employee-number order.

Each query is (start, k), where k is one-indexed. Return the employee who is the kth recipient within start's subtree, or -1 if the subtree has fewer than k employees.

Constraints

  • 1 <= n <= 200,000
  • 1 <= len(queries) <= 200,000
  • The hierarchy is a valid rooted tree.
  • Query starts are valid indices and k >= 1 .

Example behavior

If employee 2 directly manages employees 4 and 7, and 4 manages 5, transmission from 2 visits 2, 4, 5, 7 before any later sibling subtree.

Candidate clarifications

Confirm whether the start employee counts as recipient one, whether traversal is depth-first, the sibling ordering, and out-of-range behavior.

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Uber•More Software Engineer•Uber Software Engineer•Uber Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • AI Coding Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.