Reported September 2026
Airbnbdesign

In-Memory File System

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

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

Airbnb reportedly asked this one in September 2026, and the detail that trips people is the compression rule: a 7-unit file becomes 4, and decompressing it has to fit the owner's capacity again. It's an In-Memory File System, a design problem dressed up as a pile of string operations. You process a batch of ADD_USER, ADD_FILE, COPY_FILE, FIND_FILES, COMPRESS_FILE and DECOMPRESS_FILE rows and return one string each. Nothing is algorithmically deep. The risk is missing one of the validation rules under time pressure. If you blank mid-assessment, StealthCoder runs invisibly as a safety net and reads the spec for you.

The problem

Implement an in-memory file system that processes a finite ordered batch of operations. Each file has a unique path, a current stored size, an owner, and a compression state. Each non-admin user has a storage capacity equal to the maximum sum of the current stored sizes of files they own. The built-in user "admin" exists before processing begins and has unlimited capacity.
The input operations contains one string array per operation. Return one string for every operation, in the same order.
Supported operationsOperation rowBehaviorReturned string
["ADD_USER", userId, capacity]Add a non-admin user with the given nonnegative capacity. The operation fails if the ID is empty, is "admin", or already exists."true" on success; otherwise "false".
["ADD_FILE", userId, path, size]Add an uncompressed file owned by an existing user. The path must be absent, the size must be positive, the path must not end in ".COMPRESSED", and a non-admin owner must have enough remaining capacity."true" on success; otherwise "false".
["COPY_FILE", sourcePath, destinationPath]Copy an existing file to an absent path. The copy keeps the source owner, current size, compression state, and original size. The owner must have enough remaining capacity. The destination ends in ".COMPRESSED" exactly when the source is compressed."true" on success; otherwise "false".
["FIND_FILES", prefix, suffix]Find every current file path that starts with prefix and ends with suffix. Order matches by current size descending, then by path lexicographically ascending. Format each match as path(size) and join matches with ", ".The joined matches, or the empty string when none match.
["COMPRESS_FILE", userId, path]Compress an existing uncompressed file owned by userId. Rename it to path + ".COMPRESSED", which must be absent, and change its stored size from s to ceil(s / 2). Remember s as its original size."true" on success; otherwise "false".
["DECOMPRESS_FILE", userId, compressedPath]Decompress an existing compressed file owned by userId. Its path must end in ".COMPRESSED". Rename it by removing that final suffix and restore its original size. The restored path must be absent, and a non-admin owner must have enough capacity for the increase."true" on success; otherwise "false".
A failed mutation leaves all state unchanged. Repeating an already-applied mutation therefore fails unless the required source and destination state exists again later.

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

Examples
Example 1
operations = [["ADD_USER","alice","10"],["ADD_FILE","alice","/docs/a.txt","7"],["COPY_FILE","/docs/a.txt","/docs/b.txt"],["COMPRESS_FILE","alice","/docs/a.txt"],["COPY_FILE","/docs/a.txt.COMPRESSED","/docs/b.txt.COMPRESSED"],["FIND_FILES","/docs/",".COMPRESSED"],["DECOMPRESS_FILE","alice","/docs/a.txt.COMPRESSED"]]
return = ["true","true","false","true","true","/docs/a.txt.COMPRESSED(4), /docs/b.txt.COMPRESSED(4)","false"]
The first copy would exceed Alice's capacity. Compressing the 7-unit file uses 4 units, so its compressed copy fits. The two equal-size matches use path order. Decompressing either copy would raise total usage from 8 to 11, so the final operation fails without changing state.
Example 2
operations = [["ADD_FILE","admin","/odd.txt","5"],["COMPRESS_FILE","admin","/odd.txt"],["FIND_FILES","/",".COMPRESSED"],["DECOMPRESS_FILE","admin","/odd.txt.COMPRESSED"],["FIND_FILES","/",".txt"]]
return = ["true","true","/odd.txt.COMPRESSED(3)","true","/odd.txt(5)"]
Compression rounds the odd size up from 5 to 3. The admin account has unlimited capacity, and decompression restores both the original path and size.
Example 3
operations = [["ADD_USER","dev","30"],["ADD_FILE","dev","/src/z.log","3"],["ADD_FILE","dev","/src/b.log","8"],["ADD_FILE","dev","/src/a.log","8"],["FIND_FILES","/src/",".log"],["FIND_FILES","/tmp/",".log"]]
return = ["true","true","true","true","/src/a.log(8), /src/b.log(8), /src/z.log(3)",""]
Larger files appear first. Equal-size files use lexicographic path order, and a search with no matches returns the empty string.

Constraints
1 <= operations.length <= 100000.
Every row uses one of the six documented operation shapes and contains valid decimal integer text where required.
User IDs and file paths contain between 1 and 100 characters.
0 <= capacity <= 10^18.
1 <= size <= 10^9.
The sum of all stored sizes fits in a signed 64-bit integer.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The pattern is design with hash maps. Keep a map of path to a file record (owner, current size, original size, compressed flag) and a map of user to capacity and used storage. Every mutation follows the same shape: validate everything first, then change state. That gives you the 'failed mutation leaves state unchanged' rule for free. The pitfalls are all in the details. Compression uses ceil(s/2), so 5 becomes 3. Decompression restores the original size, so check the capacity increase against the restored size, not the compressed one. Copy must preserve original size and flag, and the destination suffix must match the source's compressed state. Admin skips capacity checks. FIND_FILES filters by prefix and suffix, then sorts by size descending and path ascending. A linear scan is fine. If you freeze during the live OA, StealthCoder is the hedge that hands you the structure while you keep control of the keyboard.

Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.

If this hits your live OA

You can drill 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 by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge.

Get StealthCoder

Related leaked OAs

⏵ The honest play

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

Airbnb reuses patterns across OAs. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge. Works on HackerRank, CodeSignal, CoderPad, and Karat.

In-Memory File System FAQ

What's the trick in the Airbnb In-Memory File System problem?+

Validate first, mutate second. Each operation checks every precondition (existence, suffix, capacity, absent destination) before touching state. Store original size on each file record so decompression can restore it. Track per-user used storage incrementally instead of recomputing it.

How hard is this really?+

Easy to medium on algorithms, but unforgiving on detail. There's no clever data structure. You lose points by missing a rule, like rejecting ADD_FILE paths ending in.COMPRESSED or forgetting that admin has unlimited capacity.

How should I handle FIND_FILES?+

Scan all paths, keep those where startsWith(prefix) and endsWith(suffix) both hold, then sort by size descending and path ascending. Format each as path(size), join with a comma and space, and return an empty string if nothing matches.

What are the compression edge cases?+

Compressed size is ceil(s/2), so odd sizes round up. The new path is path plus.COMPRESSED and must be absent. Only the owner can compress, and only uncompressed files. Decompress needs the suffix, an absent restored path, and enough capacity for the size increase.

How do I prepare in 48 hours?+

Write a small class with two hash maps and one method per operation. Test against the three examples, especially the failed copy and failed decompress cases. Then rehearse the capacity math: used storage changes on add, copy, compress and decompress.

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

OA at Airbnb?
Invisible during screen share
Get it