Reported July 2026
Anthropicdesign

Cloud Storage Compression and Decompression

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 reportedly dropped this one in July 2026, and it looks scarier than it is. It's a multi-operation in-memory storage simulation with users, capacity limits, and a compress/decompress pair layered on top. No clever algorithm hides in here. It's a state-management problem with a lot of small rules, and the OA rewards whoever tracks ownership and capacity without slipping. If you blank on the bookkeeping mid-assessment, StealthCoder runs invisibly as a safety net while you work through it.

The problem

Implement the compression level of an in-memory cloud storage system with user ownership and capacity limits. Return one string result per operation. Use the literal string null for an empty optional result.
Base File Operations
["ADD_FILE", name, size]: add an admin-owned file. The admin has unlimited capacity. Return true, or false when the name already exists.
["COPY_FILE", name_from, name_to]: copy a file when the source exists and the destination does not. Preserve the source owner's identity and return true; otherwise return false.
["GET_FILE_SIZE", name]: return the file size, or null when missing.
Users and Capacity
["ADD_USER", user_id, capacity]: create a unique user and return true, or false when the ID exists.
["ADD_FILE_BY", user_id, name, size]: add an owned file without exceeding capacity. Return the user's remaining capacity, or null on failure.
["UPDATE_CAPACITY", user_id, capacity]: replace the user's capacity. If current files exceed it, remove the largest files until usage fits; break equal-size ties by file name in lexicographic order. Return the number removed, or null for a missing user.
Compression
["COMPRESS_FILE", user_id, name]: require an existing file owned by the user. Replace it with name + ".COMPRESSED", preserve ownership, and halve its size. File sizes supplied to this operation are guaranteed even. Return remaining capacity, or null on failure.
The input name to COMPRESS_FILE never already ends in.COMPRESSED. ADD_FILE and ADD_FILE_BY are never used to introduce compressed names. COPY_FILE preserves the suffix.
["DECOMPRESS_FILE", user_id, name]: name ends in.COMPRESSED. Require that it exists and belongs to the user. Replace it with the suffix-free name and double its size.
Decompression fails with null if the uncompressed name already exists or the larger file would exceed the user's capacity. On success, return remaining capacity.
Runner Interface
cloudStorageCompression accepts String[][] operations and returns a String[].

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

Examples
Example 1
operations = [["ADD_USER","user1","1000"],["ADD_USER","user2","5000"],["ADD_FILE_BY","user1","/dir/file.mp4","500"],["COMPRESS_FILE","user2","/dir/file.mp4"],["COMPRESS_FILE","user3","/dir/file.mp4"],["COMPRESS_FILE","user1","/folder/non_existing_file"],["COMPRESS_FILE","user1","/dir/file.mp4"],["GET_FILE_SIZE","/dir/file.mp4.COMPRESSED"],["GET_FILE_SIZE","/dir/file.mp4"],["COPY_FILE","/dir/file.mp4.COMPRESSED","/file.mp4.COMPRESSED"],["ADD_FILE_BY","user1","/dir/file.mp4","500"],["DECOMPRESS_FILE","user1","/dir/file.mp4.COMPRESSED"],["UPDATE_CAPACITY","user1","2000"],["DECOMPRESS_FILE","user2","/dir/file.mp4.COMPRESSED"],["DECOMPRESS_FILE","user3","/dir/file.mp4.COMPRESSED"],["DECOMPRESS_FILE","user1","/dir/file.mp4.COMPRESSED"],["DECOMPRESS_FILE","user1","/file.mp4.COMPRESSED"]]
return = ["true","true","500","null","null","null","750","250","null","true","0","null","0","null","null","null","750"]
Only User 1 owns the original file. Compression reduces it from 500 to 250. The first decompression attempt lacks capacity, and a later attempt conflicts with the re-created uncompressed name. After the capacity increase, the copied compressed file can be decompressed successfully.

Reported by candidates. Source: FastPrep

Pattern and pitfall

What it really reduces to: two hash maps and careful accounting. Keep a map of file name to (size, owner) and a map of user to (capacity, used). Admin-owned files skip capacity checks. Every operation is a lookup, a validation, then a mutation. The traps are the edge rules. COPY_FILE preserves the original owner, not the caller, so the copy counts against the source owner's usage. UPDATE_CAPACITY evicts largest files first, with ties broken by lexicographic name, so sort by size descending then name ascending. Decompress must check name collision and capacity before mutating anything. Compress frees half the size, so return the new remaining capacity. Write a helper for remaining capacity and reuse it. The failure mode is partial mutation before a check fails. If you freeze on the order of checks, StealthCoder is the hedge during the live OA.

StealthCoder is the hedge for the one pattern you didn't drill. It runs invisibly during the screen share.

If this hits your live OA

You can drill Cloud Storage Compression and Decompression 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. If you're reading this with an OA window open, you're who this was built for.

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. If you're reading this with an OA window open, you're who this was built for. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Cloud Storage Compression and Decompression FAQ

What's the trick to the Anthropic cloud storage compression problem?+

There isn't an algorithm trick. Use a file map storing size and owner, plus a user map storing capacity and used bytes. Validate everything first, then mutate. Most wrong answers come from mutating state before a later check fails, or from miscounting usage on copies.

How hard is this OA really?+

Medium on difficulty, high on tedium. The logic per operation is simple, but there are many rules and the examples hide edge cases. Careful reading beats speed here. Trace the provided example by hand before submitting.

How does UPDATE_CAPACITY eviction work?+

If used space exceeds the new capacity, remove the user's largest files until usage fits. Equal sizes break ties by file name in lexicographic order. Sort that user's files by size descending, then name ascending, and pop until it fits. Return the count removed.

Who owns a copied file and who pays for it?+

The copy keeps the source owner's identity, so it counts toward that owner's usage, not whoever triggered the copy. COPY_FILE also preserves the.COMPRESSED suffix. Note it doesn't check capacity per the spec, so just add the size to the owner's used total.

How do I prepare for this in 48 hours?+

Build a small version of this class from scratch. Practice a dispatcher over operation strings, two maps, and a remaining-capacity helper. Then replay the sample by hand, especially the failed decompress cases from capacity and name conflicts. That covers nearly every bug you'll hit.

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