Skip to main content

Practice ยท 1 of 3

Reachability

Given commits โ€” a map of id โ†’ parent id (null for root) โ€” and a target id, return an array of ALL ancestor ids reachable from the target (including itself), ordered oldest-first (walk to root, then reverse).

Difficulty: intermediate

Back to lesson: Practice: History as Data โ€” Practice