FastPrepDesign a File System with Paths
Problems/Design a File System with Paths

Design a File System with Paths

Airbnb logoAirbnb● MediumINTERNPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in Airbnb software engineer intern technical interviews in 2018 and 2019. The task was to build a small file system that stores a value at each path, where a new path can only be added under a path that already exists. Values can also be read and changed. One interviewer wanted a tree of path names instead of one big map, and a follow-up asked how to delete a path.

The reports give no input format or limits. Here, you get the calls as a list of operations instead of a class. Create and update return true or false, and get returns -1 for a missing path. Delete is covered in the editorial but not tested.

Our version is about 85% the same as the reported question.

Build a small file system that stores a number at each path. A path looks like "/a" or "/a/b": it starts with "/" and lists names separated by "/". The parent of "/a/b" is "/a". A path with only one name, such as "/a", sits at the top and can always be created if it is new.

You are given a list of operations. Run them in order and return one result for each:

  • ["create", path, value]: add path and store value at it, then return "true". If path already exists, or its parent does not exist, change nothing and return "false".
  • ["get", path]: return the value stored at path, or "-1" if path does not exist.
  • ["update", path, value]: if path exists, replace its value with value and return "true". Otherwise return "false".

Function

runFileSystem(operations: String[][]) → String[]

Examples

Example 1

operations = [["create","/a","1"],["create","/a/b","2"],["get","/a/b"],["create","/c/d","3"],["get","/c"]]return = ["true","true","2","false","-1"]

/a has one name, so it can be created. /a/b works because its parent /a exists, and get returns its value 2. /c/d fails because its parent /c was never created, and get on /c returns -1.

Example 2

operations = [["create","/home","5"],["create","/home","9"],["get","/home"],["update","/home","9"],["get","/home"],["update","/work","4"]]return = ["true","false","5","true","9","false"]

The second create fails because /home already exists, so the value stays 5. update changes it to 9. The last update fails because /work does not exist.

Example 3

operations = [["create","/x","1"],["create","/x/ab","3"],["create","/x/a","2"],["get","/x/a"],["get","/x/ab"],["create","/x/c/a","4"],["get","/x/c"]]return = ["true","true","true","2","3","false","-1"]

Names are matched whole. /x/ab and /x/a are two different paths, even though ab starts with a, so both are created and keep their own values. /x/c/a fails because /x/c does not exist.

Constraints

  • 1 <= operations.length <= 104
  • Each operation is ["create", path, value], ["get", path] or ["update", path, value].
  • 2 <= path.length <= 100
  • path starts with "/" and is one or more names separated by a single "/". Each name is one or more lowercase English letters. A path never ends with "/".
  • value is a whole number from 1 to 109, written without leading zeros.

More Airbnb Phone Screen questions

  • Read Across Sound TracksPHONE SCREEN · Seen Nov 2026
  • Text JustificationPHONE SCREEN · Seen Nov 2026
  • Decode and Store StringsPHONE SCREEN · Seen Oct 2026
  • Print Sentences as TablePHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Detonate Bombs with Chain ReactionsPHONE SCREEN · Seen Aug 2026
  • Smallest Common RegionPHONE SCREEN · Seen Aug 2026
  • Longest Chain BookingPHONE SCREEN · Seen Aug 2026
  • Nested List Iterator with RemovePHONE SCREEN · Seen Jul 2026
  • Parse Query StringPHONE SCREEN · Seen May 2026
  • Pacific Atlantic Water FlowPHONE SCREEN · Seen May 2023

Similar questions at other companies

  • Design File SystemGoogle · PHONE SCREENGoogle interview questions
  • In-Memory Directory and File OperationsSquarepoint Capital · ONSITE INTERVIEWSquarepoint Capital interview questions
  • File System PathsCapital One · ONSITE INTERVIEWCapital One interview questions
  • In-Memory Filesystem CommandsPerplexity AI · PHONE SCREEN · ONSITE INTERVIEWPerplexity AI interview questions
  • File Storage ServiceCresta · PHONE SCREENCresta interview questions
  • Return Every Matching DecryptionDuolingo · PHONE SCREENDuolingo interview questions
  • Design a Food Rating SystemApple · PHONE SCREENApple interview questions
  • Hierarchical In-Memory File SystemClay · PHONE SCREEN
  • Numeric Poker OperationsRippling · PHONE SCREENRippling interview questions
  • Reference-Counted Deduplicating File SystemCitadel · PHONE SCREENCitadel interview questions

Interview reports that mention this question

  • Airbnb Intern Phone Interviews: 21 Experiences (Part 7 of 7)
  • Airbnb Intern OA and Phone Screens: 17 Experiences (Part 6 of 7)
  • Airbnb Intern OA and Onsite Rounds: 16 Experiences (Part 5 of 7)

Airbnb interview experiences

  • Airbnb SWE OA: Four-Level Banking System: 1 Experience
  • Airbnb Campus and Full-Time SWE OA / Interviews: 9 Experiences
  • Airbnb Intern OA, Diplomacy Game: 19 Experiences (Part 4 of 7)
All Airbnb interview questionsSee Airbnb hiring insights
Saved
class Solution {
    public String[] runFileSystem(String[][] operations) {
      // Write your code here.
    }
}
Checking account…