O86

In-Memory File System

Mid / Senior Engineer
Target Time: 25 - 35 Minutes
Type: ARRAY

Problem Statement & Objective

Design an in-memory file system to simulate directories, file creation, content reading, and appending.

Function Signature (Python)

inmemory_file_system(operations: list) -> list

Input & Output Contract

Output Rule:Her işlemin ürettiği çıktılardan oluşan liste.

System Constraints

1 <= islemler.length <= 1000
1 <= path.length <= 100
Path '/' ile başlar

Example Execution Walkthrough

islemler = [['ls', '/'], ['mkdir', '/a/b/c'], ['add_content', '/a/b/c/d', 'hello'], ['ls', '/'], ['read_content', '/a/b/c/d']]
ls / -> []
mkdir /a/b/c -> None
add_content -> None
ls / -> ['a']
read_content -> 'hello'
Cevap: [[], None, None, ['a'], 'hello']

Example Test Scenarios (3)

Example 1: Temel Dosya Sistemi
Input:[[["ls","/"],["mkdir","/a/b/c"],["add_content","/a/b/c/d","hello"],["ls","/"],["read_content","/a/b/c/d"]]]
Expected Output:[[],null,null,["a"],"hello"]
Example 2: İçerik Ekleme (Append)
Input:[[["mkdir","/docs"],["add_content","/docs/f1","abc"],["add_content","/docs/f1","def"],["read_content","/docs/f1"]]]
Expected Output:[null,null,null,"abcdef"]
Example 3: Dosyada ls
Input:[[["add_content","/test.txt","selam"],["ls","/test.txt"]]]
Expected Output:[null,["test.txt"]]
Loading Python Editor...
Input Parameters
[
  [
    [
      "ls",
      "/"
    ],
    [
      "mkdir",
      "/a/b/c"
    ],
    [
      "add_content",
      "/a/b/c/d",
      "hello"
    ],
    [
      "ls",
      "/"
    ],
    [
      "read_content",
      "/a/b/c/d"
    ]
  ]
]
Expected Output
[
  [],
  null,
  null,
  [
    "a"
  ],
  "hello"
]