Reported September 2026
Claydesign

Hierarchical In-Memory File System

Reported by candidates from Clay's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Clay OA. Under 2s to a working solution.
Founder's read

Clay reported this one in September 2026, and it looks like a short design question until MOVE shows up. You're building an in-memory file system with MKDIR, WRITE, READ, LIST, MOVE and DELETE, and every operation must return a string. The pattern is design on top of a tree of nodes. Most candidates get the first four commands working fast, then lose points on cycles, collisions and root handling. If you've got an OA invite for this, the work is in the edge cases, not the data structure. StealthCoder is the safety net if you blank mid-assessment, but knowing where this breaks is the better hedge.

The problem

Process operations on an in-memory hierarchy rooted at /.
MKDIR path recursively creates missing folders and returns true, unless a path component is a file.
WRITE path content creates or replaces a file when its parent folder exists and returns whether it succeeded.
READ path returns file content or the empty string.
LIST path returns direct children sorted as comma-separated D:name or F:name.
MOVE source destinationFolder moves a file or folder under an existing folder, preserving its name. Reject root moves, cycles, and collisions.
DELETE path removes a file or a folder and all descendants. Root cannot be deleted.
Return one string for every operation.

Function
runHierarchicalFileSystem(operations: String[][]) → String[]

Examples
Example 1
operations = [["MKDIR","/a/b"],["WRITE","/a/b/note","hello"],["READ","/a/b/note"],["LIST","/a/b"],["DELETE","/a"],["READ","/a/b/note"]]
return = ["true","true","hello","F:note","true",""]
Recursive creation, file access, listing, and cascading deletion are applied in order.
Example 2
operations = [["MKDIR","/src/pkg"],["MKDIR","/dst"],["WRITE","/src/pkg/a","x"],["MOVE","/src/pkg","/dst"],["LIST","/dst"],["READ","/dst/pkg/a"]]
return = ["true","true","true","true","D:pkg","x"]
Moving a folder rewrites every descendant path.

Constraints
1 <= operations.length <= 10000
Paths are normalized absolute paths with no trailing slash except /.
Names and file contents contain no commas.

Reported by candidates. Source: FastPrep

Pattern and pitfall

Model the hierarchy as a tree of nodes. Each node has a name, an isFile flag, content, and a map of children. Parse each path by splitting on slash and walk from the root. The trick is MOVE. Reparenting a node means you never rewrite descendant paths, because paths are derived by walking. That's why a nodes-and-pointers design beats a flat map of full path strings. The edge case that breaks naive solutions is the cycle check. Moving /a into /a/b/c must fail, so walk up from the destination and reject if you hit the source. Also reject root moves, name collisions in the destination, and a destination that is a file or missing. MKDIR must fail if any component is a file. LIST sorts by name and prefixes D: or F:. If you freeze during the live OA, StealthCoder can step in as a hedge, but write the cycle check yourself first.

Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.

If this hits your live OA

You can drill Hierarchical In-Memory File System cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made for the candidate who got the OA invite this morning and has 72 hours, not six months.

Get StealthCoder

Related leaked OAs

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as design in memory file system. If you have time before the OA, drill that.

⏵ The honest play

You've seen the question. Make sure you actually pass Clay's OA.

Clay reuses patterns across OAs. Made for the candidate who got the OA invite this morning and has 72 hours, not six months. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Hierarchical In-Memory File System FAQ

What's the trick in the Clay hierarchical file system problem?+

Use a tree of nodes with child maps instead of a flat path-to-content map. MOVE then becomes a pointer change, since descendants keep their relative structure. The rest is careful validation: parent exists, parent is a folder, no collisions, no cycles.

How do I detect a cycle on MOVE?+

Walk from the destination folder up through parent pointers to the root. If you meet the source node, the move would put a folder inside itself or a descendant, so return false. Store a parent pointer on each node to make this cheap.

What should MKDIR do when a path component is a file?+

Return false. While walking and creating folders, if an existing component is a file, stop and fail. Be aware that earlier folders may already have been created, so check the whole path first if you want no partial changes.

How hard is this really?+

Medium on difficulty, but the volume of rules is what trips people. Up to 10000 operations means simple maps and walks are fast enough. The risk is missing a rule, like root deletion, collisions on MOVE, or WRITE into a missing parent.

How do I prepare in 48 hours?+

Write the node class and a path-walk helper once, then implement each command against it. Test with both examples, then add your own cases: move into self, move onto an existing name, delete root, list an empty folder, and read a folder path.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Clay.

OA at Clay?
Invisible during screen share
Get it