← 返回 bytedance 的题目列表Design In-Memory File System with Create and Get Operations
类型:online_judge
bytedance
Design an in-memory file system to simulate basic file operations. Implement the following interfaces:
Create path createPath(path: str, value: int) -> bool: Create a new file or directory at given path and set its value.
Get value get(path: str) -> int: Get the value of the given path.
These operations should follow Unix-style path names, which means paths use "/" as the root directory and through which all parts must exist (only root " /" always exists). If the path already exists or the parent path does not exist, createPath should return false (failure). Path names contain only letters, digits, " / " and underscores. Value is guaranteed to be a non-negative integer. Implement the above interfaces using appropriate data structures.
Example
Input
createPath("/a", 1)
get("/a")
createPath("/a/b", 2)
get("/a/b")