Reported August 2026
Anthropicdesign

Cloud Storage System

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

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

Anthropic's Cloud Storage System showed up in candidate reports in August 2026, and the first attempt usually dies on the same thing: treating backups as references instead of snapshots. It's a design problem. One in-memory class, four levels stacked on each other, and a stream of operation rows you have to answer one by one. Files, a ranked prefix search, users with capacity, then backup and restore. Nothing is algorithmically hard. The risk is tiny rules you forget under pressure. If you blank mid-OA, StealthCoder sits invisibly on your screen as a safety net. Know the traps before you open it.

The problem

Implement an in-memory cloud storage system. The original assessment exposes a stateful class whose features are unlocked cumulatively across four levels. Do not access the real file system.
FastPrep operation-sequence adapter
FastPrep calls cloudStorageSystem(operations) once. Process the rows of operations from left to right while preserving one shared storage state. Each row begins with an uppercase operation name followed by that method's string arguments.
Return one string-array row for every input operation:
Encode a Boolean as ["true"] or ["false"].
Encode an integer as a one-element row such as ["10"].
Encode None as an empty row [].
For GET_N_LARGEST, return its list of formatted file strings directly; an empty list is also [].
Level 1: file operations
["ADD_FILE", name, size] implements add_file(name, size). Add a new file with the given byte size. Return true, or false if the name already exists. Files added this way belong to the unlimited admin user.
["GET_FILE_SIZE", name] implements get_file_size(name). Return the file size, or None if the file does not exist.
["DELETE_FILE", name] implements delete_file(name). Delete the file and return its former size, or return None if it does not exist.
Level 2: largest files
["GET_N_LARGEST", prefix, n] implements get_n_largest(prefix, n). Select files whose names start with prefix, order them by size descending and then by name lexicographically ascending, and return at most n entries formatted as name(size). Return every match when fewer than n exist and an empty list when none exist.
Level 3: users and capacity
All users share the same global file-name space.
["ADD_USER", userId, capacity] implements add_user(userId, capacity). Create a user with that byte limit. Return false when the user already exists and true otherwise.
["ADD_FILE_BY", userId, name, size] implements add_file_by(userId, name, size). Add the file for that user only when the user exists, the name is free, and the user's total owned size would not exceed the capacity. Return the remaining capacity after success, or None on failure.
["MERGE_USER", userId1, userId2] implements merge_user(userId1, userId2). If both users exist and are distinct, transfer every file owned by userId2 to userId1, combine their capacity limits, delete userId2, and return userId1's remaining capacity. Return None when either user is missing or the IDs are equal. Neither merge argument is admin.
Level 4: backup and restore
["BACKUP_USER", userId] implements backup_user(userId). Replace that user's previous backup with an independent snapshot of the names and sizes of all files currently owned by the user. Return the number of backed-up files, or None when the user does not exist.
["RESTORE_USER", userId] implements restore_user(userId). Return None when the user does not exist. Otherwise delete all files currently owned by the user. If a backup exists, restore each backed-up file whose name is not currently occupied by another user; skip occupied names. With no backup, leave the user with no files. Return the number of restored files.
Normal file additions, deletions, and other users' operations never mutate a stored backup. Merging leaves userId1's backup unchanged and deletes userId2's backup. Restoring files does not change the user's capacity limit.

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

Examples
Example 1
operations = [["ADD_FILE","/dir/file1.txt","5"],["ADD_FILE","/dir/file2","20"],["ADD_FILE","/dir/deeper/file3.mov","9"],["GET_N_LARGEST","/dir","2"],["ADD_FILE","/big_file.mp4","20"],["GET_N_LARGEST","/","2"],["DELETE_FILE","/dir/file1.txt"],["GET_FILE_SIZE","/dir/file1.txt"]]
return = [["true"],["true"],["true"],["/dir/file2(20)","/dir/deeper/file3.mov(9)"],["true"],["/big_file.mp4(20)","/dir/file2(20)"],["5"],[]]
The first three operations add files. The first ranking returns the two largest names under /dir. After adding /big_file.mp4, the two size-20 files tie, so their names decide the order. Deleting /dir/file1.txt returns its former size, and the following lookup returns an empty row for None.
Example 2
operations = [["ADD_USER","user1","100"],["ADD_USER","user2","40"],["ADD_FILE_BY","user1","/a","60"],["ADD_FILE_BY","user2","/b","10"],["ADD_FILE_BY","user2","/c","30"],["MERGE_USER","user1","user2"],["GET_FILE_SIZE","/b"],["ADD_FILE_BY","user2","/d","1"],["ADD_FILE_BY","user1","/d","40"],["MERGE_USER","user1","user1"]]
return = [["true"],["true"],["40"],["30"],["0"],["40"],["10"],[],["0"],[]]
Before the merge, user1 has 40 bytes remaining and user2 has none. The merge transfers /b and /c, deletes user2, and leaves user1 with 40 bytes. Calls for the deleted user and a self-merge return empty rows.
Example 3
operations = [["ADD_USER","user","100"],["ADD_FILE_BY","user","/file3.mp4","60"],["ADD_FILE_BY","user","/file4.txt","10"],["BACKUP_USER","user"],["DELETE_FILE","/file3.mp4"],["DELETE_FILE","/file4.txt"],["ADD_FILE","/file3.mp4","140"],["ADD_FILE_BY","user","/dir/file5.new","20"],["RESTORE_USER","user"],["GET_FILE_SIZE","/file3.mp4"],["GET_FILE_SIZE","/file4.txt"],["GET_FILE_SIZE","/dir/file5.new"]]
return = [["true"],["40"],["30"],["2"],["60"],["10"],["true"],["80"],["1"],["140"],["10"],[]]
The backup remembers /file3.mp4 and /file4.txt. Before restore, the admin occupies the former name and the user owns /dir/file5.new. Restore deletes the user's current file, skips the conflicting name, restores /file4.txt, and returns 1.

Constraints
Every operation row is well-formed and uses one of the operation names described above.
The integer arguments from the source are supplied as base-10 strings that fit the signed 64-bit runtime representation.
The input does not create collisions between file and directory names.
All users share one file-name namespace; admin exists initially and has unlimited capacity.
Process operations in the supplied order. The system is empty initially except for admin.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The pattern is design with hash maps. Keep one global map of name to (size, owner), a map of users to capacity, and a map of users to backup snapshots. The mistake that sinks first attempts is storing the backup as a live reference. BACKUP_USER must copy names and sizes into an independent dict, so later deletes don't change it. Second trap: RESTORE_USER deletes everything the user owns first, then restores only names not held by another user, and the return is the restored count. Third: MERGE_USER adds capacities, moves ownership, drops userId2 and its backup, and leaves userId1's backup alone. Remaining capacity is capacity minus owned size, so compute it from the files or track used bytes carefully. GET_N_LARGEST just filters by prefix and sorts by (-size, name). A simple scan is fine. If you stall on output encoding, StealthCoder can show the adapter format: None is [], booleans are strings.

If you see this problem in your OA tomorrow, the play is to recognize the pattern in 30 seconds. StealthCoder buys you that recognition.

If this hits your live OA

You can drill Cloud Storage 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. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken.

Get StealthCoder

Related leaked OAs

⏵ The honest play

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

Anthropic reuses patterns across OAs. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Cloud Storage System FAQ

How hard is the Anthropic Cloud Storage System OA really?+

Medium on difficulty, high on detail. There's no tricky algorithm, just a lot of small rules across four levels. Candidates lose points on edge cases like backup independence and occupied names during restore, not on data structures.

What's the trick to the backup and restore level?+

Snapshot by copying. BACKUP_USER stores a fresh dict of name and size, replacing any older one. RESTORE_USER first deletes all the user's current files, then re-adds backed-up files whose names aren't owned by someone else. Return how many came back.

How should I store files and users?+

Use one global dict from file name to size and owner, since all users share one name space. Add a dict of user to capacity and another of user to backup. Files added with plain ADD_FILE belong to an unlimited admin owner.

How do I handle the output format for the operation rows?+

Every operation returns a string-array row. Booleans become ["true"] or ["false"], integers become one-element rows, None becomes an empty row, and GET_N_LARGEST returns its formatted list directly. Empty list is also []. Write a small helper and use it everywhere.

How do I prepare in 48 hours for this kind of design OA?+

Write the class from scratch once, level by level, and test the ties and failure cases. Check sort order by size descending then name, merge behavior, and capacity after restore. Then re-read the rules for None returns, since that's where bugs hide.

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

OA at Anthropic?
Invisible during screen share
Get it