Cloud Storage File Versioning
Reported by candidates from Anthropic's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The mistake that sinks most first attempts at Anthropic's Cloud Storage File Versioning question is forgetting that deleting a version renumbers every version above it. This one was reported in July 2026. It's a design-style simulation: a map from file name to a list of sizes, plus a prefix query that sorts. Nothing exotic, but five operations and a few edge cases leave plenty of room for sloppy bugs. If you blank mid-assessment, StealthCoder runs invisibly on your desktop as a safety net. Know the shape before you open the OA and you won't need it.
The problem
Implement an in-memory cloud storage system that keeps every version of an overwritten file. Process the operations in order and return one string result per operation. File Operations ["ADD_FILE", file_name, size]: create a file and return created. If the name already exists, append a new version with the supplied size and return overwritten. Versions are numbered from 1. ["GET_FILE_SIZE", file_name]: return the latest version's size, or an empty string if the file does not exist. ["MOVE_FILE", name_from, name_to]: move the file and all of its versions. Return false if the source is missing or the destination already exists; otherwise return true. ["GET_LARGEST_N", prefix, n]: return up to n prefix-matching files, using each file's latest size. Sort by size descending and file name ascending; format as name(size), name(size). Return an empty string when no file matches. Version Operations ["GET_VERSION", file_name, version]: return that version's size, or an empty string if the file or version does not exist. ["DELETE_VERSION", file_name, version]: permanently delete that version and return true. Return false when it does not exist. After deletion, every higher version number decreases by one. Deleting a file's only version permanently removes the file. Function cloudStorageFileVersioning(operations: String[][]) → String[] Examples Example 1 operations = [["ADD_FILE","/file-a.txt","6"],["ADD_FILE","/file-a.txt","3"],["GET_VERSION","/file-a.txt","2"],["GET_VERSION","/file-a.txt","4"],["GET_VERSION","/file-a.txt","1"],["DELETE_VERSION","/file-a.txt","1"],["GET_VERSION","/file-a.txt","1"]] return = ["created","overwritten","3","","6","true","3"] The second write creates version 2. Deleting version 1 renumbers the former version 2 to version 1. Constraints All integer parameters are between 1 and 200.
Reported by candidates. Source: FastPrep
Pattern and pitfall
Store each file as a name mapped to an ordered list of sizes. Version k is index k-1, so renumbering after a delete comes free: remove the element and everything after it shifts down. That's the trick. Don't store explicit version numbers, or you'll be rewriting them on every delete. ADD_FILE appends to the list. GET_FILE_SIZE reads the last element. MOVE_FILE moves the whole list under a new key, after checking the source exists and the destination doesn't. Deleting the only version must remove the key entirely, or a later ADD_FILE returns overwritten instead of created. GET_LARGEST_N filters by prefix, sorts by latest size descending then name ascending, takes n, and formats as name(size). Return an empty string when nothing matches. Constraints are tiny, so a full scan per query is fine. If the edge cases tangle on the live OA, StealthCoder is your hedge.
The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.
You can drill Cloud Storage File Versioning 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 for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Anthropic's OA.
Anthropic reuses patterns across OAs. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Cloud Storage File Versioning FAQ
What's the trick in the Anthropic Cloud Storage File Versioning problem?+
Keep a list of sizes per file and treat version k as index k-1. Deleting a version then renumbers everything above it automatically. If you store version numbers separately, you'll have to fix them after each delete, and that's where most bugs come from.
How hard is this OA really?+
Medium on difficulty, high on bug surface. No advanced algorithm is needed. It's a hash map of lists plus a sort. Candidates lose points on edge cases: deleting the last version, moving onto an existing name, and tie-breaking in the largest-N output.
What happens when the only version of a file is deleted?+
The file is removed completely. Delete the key from the map when the list becomes empty. After that, GET_FILE_SIZE returns an empty string and a new ADD_FILE returns created, not overwritten. Skipping this step is a common silent failure.
How should GET_LARGEST_N sort and format results?+
Filter files whose name starts with the prefix, using each file's latest size. Sort by size descending, then name ascending. Take the first n and join them as name(size) with a comma and space. If nothing matches, return an empty string.
How do I prepare for this in 48 hours?+
Write the solution once from scratch with a map of lists. Then test the edge cases by hand: delete a middle version, delete the only version, move to an existing name, and query a prefix with tied sizes. Example 1 covers the renumbering case. That's about an hour of work.