← 返回 doordash 的题目列表Design a File System using Trie
类型:online_judge
Design a File System using Trie with the following functionalities:
create(path: str, value: int): Creates a new unique path and returns whether the operation was successful.
get(path: str): Returns the value associated with a given path.
Paths consist of names separated by slashes / and each name consists of alphanumeric characters. If the path already exists or its parent path doesn't exist, the create operation should return false. Both path and value are guaranteed to be less than or equal to 100. Provide at least three test cases.
Test Cases
Input: create("/a", 1) / Output: true
Input: create("/a/b", 2) / Output: true
Input: get("/a/b") / Output: 2
Example
Input
create("/a", 1)