InterviewDB
Experience
Root IDs: Find All Root Nodes in a Forest Given Parent Pointers
phone
Interview Experience
Problem You are given a list of (node_id, parent_id) pairs representing a forest (collection of trees). A root node is one that does not appear as a child of any other node. Return all root node IDs in sorted order. Follow-ups What if the input contains a cycle? How would you detect and report it? How would you reconstruct the full tree structure (children mapping) from this edge list? If node_id values are strings instead of integers, how does your solution change? How would you find all leaf n…
Full Details
🔒
Unlock all Ziphq questions
Full insider details, leaked discussions, and candidate experiences.
Get full access — $100 a year, unlimited accessAbout This Question
This is a candidate experience report from a ziphq interview during the phone round.
It covers the following topics: Coding, Phone, Onsite, Strings .
More Ziphq Interview Questions
InterviewDB
Catch Me If You Can: Optimal Pursuer Movement on a Grid
InterviewDB
Conditional Check: Evaluate Boolean Expressions with Variables
InterviewDB
Ziphq SWE Phone - Convert Email
InterviewDB
Display Strings: Format and Wrap Text to Fit a Fixed-Width Screen
InterviewDB
Furthest Distance Reachable with Limited Fuel Stops