← Reddit Interview Insights

Reddit·Software Engineer·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
Jul 2026Remote

Summary

Reddit coding interview focused entirely on a reporting chain problem, basically a tree traversal setup with multiple sub-problems. The tricky part was that each sub-question had a different expected output format, which I didn't fully register until I was already mid-answer.

Questions Asked (3)

Q1

Given an employee/manager hierarchy, write a query to find who a given employee's manager is.

Algorithms & Data StructuresData Modeling
Author's notes

Pretty straightforward self-join on the same table.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the schema and whether the hierarchy is stored as a self-referencing table (employee_id, manager_id) or as a closure table. Then write a simple self-join or recursive CTE to retrieve the manager for the given employee, and discuss edge cases like the CEO having no manager.

Pro tip: Mention that for frequent manager lookups, a self-join on an indexed manager_id column is efficient, but if the hierarchy is deep and you need all ancestors, a recursive CTE or closure table is better. This shows you consider performance and scalability.

1. Clarify the schema

Ask whether the hierarchy is stored in a single table with employee_id and manager_id columns, or in a separate relationship table. Confirm the column names and data types.

2. Identify the query pattern

Determine if the question asks for the immediate manager only or the entire chain of command. For immediate manager, a self-join suffices; for the chain, use a recursive CTE.

3. Write the SQL

For immediate manager: SELECT m.* FROM employees e JOIN employees m ON e.manager_id = m.employee_id WHERE e.employee_id = ?. For chain: use WITH RECURSIVE to traverse upward.

4. Handle edge cases

Discuss what happens if the employee is the CEO (manager_id is NULL) or if the employee ID does not exist. Mention using LEFT JOIN to return NULL for the CEO.

5. Optimize and discuss alternatives

Mention indexing on manager_id for performance. If the hierarchy is large and queried often, consider a closure table or nested set model for faster ancestor queries.

Key Points to Mention

  • Self-referencing table design (employee_id, manager_id)
  • Self-join vs recursive CTE for hierarchical queries
  • Handling NULL manager_id for top-level employees
  • Indexing manager_id for performance
  • Closure table or nested set model for deep hierarchies
  • SQL dialect differences (e.g., WITH RECURSIVE in PostgreSQL vs CONNECT BY in Oracle)

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q2

Write a query to list all direct and indirect reports under a given manager.

Algorithms & Data StructuresData Modeling
Author's notes

This is where I started to stumble.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the schema (e.g., employees table with id and manager_id) and whether the hierarchy is a tree or can have cycles. Then present a recursive CTE solution (or iterative approach) that traverses from the given manager down to all descendants, and discuss performance considerations.

Pro tip: Mention that recursive CTEs are ANSI SQL and supported by most databases, but if the interviewer asks about a specific system, adapt (e.g., CONNECT BY for Oracle). Also, proactively discuss how to handle cycles or depth limits to show robustness.

1. Clarify requirements and schema

Ask about the table structure (e.g., employees with id, manager_id), whether the hierarchy is a tree, and if cycles are possible. Confirm the desired output (list of employee ids or full rows).

2. Choose traversal method

Decide between recursive CTE (standard) or iterative application-level traversal. Explain the trade-offs (e.g., recursive CTE is set-based and efficient for moderate depth).

3. Write the recursive query

Use a recursive CTE: anchor member selects direct reports of the given manager; recursive member joins employees to the CTE on manager_id = employee.id. Include a depth column if needed.

4. Handle edge cases and performance

Discuss cycle detection (e.g., using a path array or depth limit), indexing on manager_id, and potential performance issues with deep hierarchies.

5. Test and explain

Walk through a small example to verify correctness, and explain how the query works step by step. Mention alternative approaches if the database doesn't support recursive CTEs.

Key Points to Mention

  • Recursive CTE syntax (WITH RECURSIVE) and its components (anchor, recursive member, UNION ALL).
  • Schema assumptions: employees table with id and manager_id columns.
  • Cycle detection or depth limiting to prevent infinite loops.
  • Indexing on manager_id for performance.
  • Alternative approaches: iterative BFS/DFS in application code, or database-specific features (e.g., Oracle CONNECT BY).
  • Output format: whether to return distinct employee ids or full rows, and ordering.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q3

Find the lowest common manager of two given employees in the hierarchy.

Algorithms & Data StructuresData Modeling
Author's notes

Honestly the most interesting part of the whole thing.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the hierarchy representation (e.g., tree with parent pointers or adjacency list) and define 'lowest common manager' as the deepest node that is an ancestor of both employees. Then choose an algorithm: if parent pointers exist, find intersection of ancestor paths; otherwise, use a recursive post-order traversal to find the lowest node whose subtree contains both employees.

Pro tip: Discuss trade-offs between time and space complexity, and mention that in a real system like Reddit, the hierarchy might be a graph with multiple managers, so you'd need to handle cycles or use a union-find approach.

1. Clarify the problem and assumptions

Ask about the data structure (tree vs. graph, parent pointers, etc.) and confirm the definition of 'lowest common manager' (deepest common ancestor).

2. Choose an approach

Decide between path-based (if parent pointers) or recursive traversal (if tree). Consider iterative vs. recursive and space constraints.

3. Walk through an example

Trace the algorithm on a small hierarchy to verify correctness and edge cases (e.g., one employee is the manager of the other).

4. Analyze complexity

State time and space complexity (e.g., O(n) time, O(h) space for recursion) and discuss optimizations.

5. Handle edge cases and extensions

Mention cases like employees not in hierarchy, multiple managers, or large hierarchies requiring iterative solutions.

Key Points to Mention

  • Definition of lowest common manager (LCA in a tree)
  • Data structure representation: tree with parent pointers vs. adjacency list
  • Algorithm: recursive post-order traversal or path intersection
  • Time and space complexity analysis
  • Edge cases: one employee is ancestor of the other, employees not found
  • Real-world considerations: multiple managers, cycles, scalability

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.