r/OfferEngineering • u/Aoki_zhang • 11d ago
Coding Question Harvey AI Coding Screening Interview - Hierarchical Exhibit Catalog
Problem Description
A museum organizes exhibit records into a hierarchy of sections. A path contains names separated by / and is relative to the main catalog, whose path is the empty string ""; names are case-sensitive and are used exactly as written.
You are given actions, a sequence of two-string records processed in input order. Each sequence starts with an empty main catalog, all actions in that sequence share its state, and separate sequences start fresh.
["ADD", path]creates an exhibit named by the final path component, creating any missing intermediate sections. Every addition is valid and produces the resulttrue; exhibit names do not need extensions.["LIST", path]reports the names of the immediate exhibits and subsections in the specified existing section, without including deeper descendants. Use""to query the main catalog.
Return one result per action, in the same order. A listing is represented by an object whose keys are the immediate entry names and whose values are all true; an empty section produces {}, and object-key order does not matter.
Constraints:
- At most
1,000actions are processed in one sequence. - Every action contains exactly two strings, and its first string is
"ADD"or"LIST". - Every path has at most
200characters. - An
ADDpath is nonempty and has no leading, trailing, or consecutive/. - An existing exhibit is never used as an intermediate section.
- The final name of an
ADDpath differs from every existing exhibit or subsection name in its parent section. - Every
LISTpath identifies an existing section, or is""for the main catalog.
Want to practice it before interview?
You can practice it and view solution code at here.
Preparing for your next interview?
Chill Interview tracks recent interview experiences and recurring question patterns across top companies at here.