Your question is Efficient Traversal of Complex Structures. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Bloomberg Terminal content can be organized as nested topic folders and instruments. Given the root of a tree and a target identifier, return the path from the root to the first matching node using an efficient traversal.
Each node is represented as a dictionary with an id string and an optional children list containing child nodes. The hierarchy is a tree, node identifiers are unique, and children must be searched from left to right. Return an empty list if the target does not exist.
Implement find_path(root, target).
root, a dictionary representing the root node, and target, a string identifier.[] when no match exists.def find_path(root, target):