PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/ZipHQ

Find root IDs and paths

Last updated: Mar 29, 2026

Quick Overview

This question evaluates understanding of graph/tree relationships, identification of root nodes, and path reconstruction from parent references, assessing algorithmic reasoning and data-structure familiarity.

  • Medium
  • ZipHQ
  • Coding & Algorithms
  • Software Engineer

Find root IDs and paths

Company: ZipHQ

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Technical Screen

You are given a collection of string blocks, each represented as a JSON object with fields {"id": string, "parentId": string | null}. A block is a root if it has no parent (parentId is null or the referenced parent does not appear). 1) Write a function that returns all root ids from the input. 2) Follow-up: given a target id, return the path of ids from its root to that id. Explain your approach, the data structures you use, and analyze time and space complexity.

Quick Answer: This question evaluates understanding of graph/tree relationships, identification of root nodes, and path reconstruction from parent references, assessing algorithmic reasoning and data-structure familiarity.

Related Interview Questions

  • Find shortest path on infinite grid - ZipHQ (hard)
  • Maximize non-adjacent sum on an N-ary tree - ZipHQ (medium)
  • Find flush and straight groups in cards - ZipHQ (medium)
  • Compute maximum sum in a tree without adjacency - ZipHQ (Medium)
ZipHQ logo
ZipHQ
Aug 11, 2025, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
33
0

You are given a collection of string blocks, each represented as a JSON object with fields {"id": string, "parentId": string | null}. A block is a root if it has no parent (parentId is null or the referenced parent does not appear).

  1. Write a function that returns all root ids from the input.
  2. Follow-up: given a target id, return the path of ids from its root to that id. Explain your approach, the data structures you use, and analyze time and space complexity.

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

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

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

Product

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

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL 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.