New
ML System Design & SQL tracks just landed
See what's new
×
Question Bank
Pricing
Blog
Forum
HOT
JobRadar
NEW
Referral
Description
Solution
Discussion
Submissions
Ask AI
Question Bank
Hudson River Trading
Coding Question
AI Insights
Quick Summary
Reconstruct a tree structure from a flat list where each element defines a node and references its children by array index.
Identify the unique root by tracking which node index never appears as a child reference.
Execute an iterative preorder traversal to output node key-value pairs in the specified visitation order.
What This Tests
Tree reconstruction from adjacency-style arrays
Root detection using index tracking or set operations
Iterative depth-first traversal implementation
Array indexing and state management without explicit object graphs
Common Patterns
Graph Traversal
DFS/BFS
Hashing
Collapse
Hint 1
Hint 2
Hint 3
What Interviewers May Ask Next
Ask AI Assistant
Ask AI Assistant
Ask me anything about this coding question!
Qwen
Qwen3.6-Flash
0/2000
Auto
Debug
Run
Submit
Test Cases
Input
Output
Expected