← Intuit Interview Insights

Intuit·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
May 2026

Summary

Intuit technical phone screen centered on tree reconstruction from a parent array, with follow-up queries layered on top. Pretty standard stuff for a mid-level SWE role but the breadth of follow-ups they could ask kept me on edge the whole time.

Questions Asked (1)

Q1

Given a parent array representing a rooted tree, reconstruct the tree structure and answer queries on it such as node depth, subtree sizes, children ordering, lowest common ancestor, or root-to-leaf path aggregations.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

This one sprawled way more than I expected.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the exact queries and constraints, then propose building an adjacency list from the parent array and preprocessing with DFS/BFS to compute depths, subtree sizes, and Euler tour timestamps. For LCA, use binary lifting or Euler tour + RMQ, and for path aggregations, use prefix sums along root-to-node paths. Discuss trade-offs between preprocessing time, query time, and memory.

Pro tip: Mention that the parent array itself can be used for O(1) parent lookup, and that an Euler tour with a segment tree can answer many subtree queries in O(log n) after O(n) preprocessing. This shows you understand the underlying structure and can optimize for the specific query mix.

1. Clarify requirements and constraints

Ask about the number of nodes, number of queries, types of queries, and whether the tree is static. This determines the preprocessing and query strategy.

2. Build the tree representation

Convert the parent array into an adjacency list (children lists) in O(n) time. Optionally, compute depths and subtree sizes via a single DFS.

3. Preprocess for efficient queries

For LCA, build binary lifting table or Euler tour + sparse table. For subtree queries, compute Euler tour entry/exit times. For path aggregations, compute prefix sums from root.

4. Answer queries using preprocessed data

Use the appropriate data structure: binary lifting for LCA, Euler tour with segment tree for subtree aggregates, and prefix sums for path sums. Explain the time complexity per query.

5. Discuss trade-offs and edge cases

Compare approaches (e.g., binary lifting vs. Euler tour + RMQ) in terms of preprocessing time, query time, and memory. Handle edge cases like root, single node, and deep trees.

Key Points to Mention

  • Building adjacency list from parent array in O(n) time and space.
  • Computing depth and subtree size with a single DFS/BFS.
  • Euler tour technique for subtree queries (entry/exit times).
  • Binary lifting for LCA with O(n log n) preprocessing and O(log n) per query.
  • Prefix sums along root-to-node paths for path aggregations.
  • Trade-offs between different preprocessing methods (e.g., binary lifting vs. Euler tour + RMQ).

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