PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Snowflake

Implement an in-memory file system

Last updated: Mar 29, 2026

Quick Overview

This question evaluates a candidate's ability to design and implement in-memory file system data structures and APIs, covering hierarchical directory modeling, path parsing, file content management, and efficient mutable state handling.

  • hard
  • Snowflake
  • Coding & Algorithms
  • Software Engineer

Implement an in-memory file system

Company: Snowflake

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: hard

Interview Round: Technical Screen

Implement an **in-memory file system** supporting basic directory and file operations. You must support the following methods (names are illustrative; any equivalent interface is fine): 1. `ls(path)` - If `path` is a file path, return a list containing **only the file name**. - If `path` is a directory path, return the names of **files and subdirectories directly under it**, sorted lexicographically. 2. `mkdir(path)` - Create a directory at the given absolute path. - Create any missing intermediate directories. 3. `addContentToFile(filePath, content)` - If the file does not exist, create it. - Append `content` to the existing file content. 4. `readContentFromFile(filePath)` - Return the full content of the file. ### Notes / Constraints - Paths are absolute and use `/` as the separator. - The root directory is `/`. - Directory and file names consist of lowercase letters (you may assume no invalid characters). - The system is in-memory only (no persistence). - Aim for reasonable time complexity per operation.

Quick Answer: This question evaluates a candidate's ability to design and implement in-memory file system data structures and APIs, covering hierarchical directory modeling, path parsing, file content management, and efficient mutable state handling.

Related Interview Questions

  • Solve Matrix and Array Distance Problems - Snowflake (medium)
  • Solve Array Distance and Wiki Navigation - Snowflake (medium)
  • Implement Document Predicate APIs - Snowflake (medium)
  • Find Shortest Wiki Click Path - Snowflake (medium)
  • Compute Inherited Role Privileges - Snowflake (hard)
Snowflake logo
Snowflake
Jan 6, 2026, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
12
0
Loading...

Implement an in-memory file system supporting basic directory and file operations.

You must support the following methods (names are illustrative; any equivalent interface is fine):

  1. ls(path)
    • If path is a file path, return a list containing only the file name .
    • If path is a directory path, return the names of files and subdirectories directly under it , sorted lexicographically.
  2. mkdir(path)
    • Create a directory at the given absolute path.
    • Create any missing intermediate directories.
  3. addContentToFile(filePath, content)
    • If the file does not exist, create it.
    • Append content to the existing file content.
  4. readContentFromFile(filePath)
    • Return the full content of the file.

Notes / Constraints

  • Paths are absolute and use / as the separator.
  • The root directory is / .
  • Directory and file names consist of lowercase letters (you may assume no invalid characters).
  • The system is in-memory only (no persistence).
  • Aim for reasonable time complexity per operation.

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Snowflake•More Software Engineer•Snowflake Software Engineer•Snowflake Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.