1166. Design File System
https://leetcode.com/problems/design-file-system
Description
You are asked to design a file system that allows you to create new paths and associate them with different values.
The format of a path is one or more concatenated strings of the form: /
followed by one or more lowercase English letters. For example, "/leetcode"
and "/leetcode/problems"
are valid paths while an empty string ""
and "/"
are not.
Implement the FileSystem
class:
bool createPath(string path, int value)
Creates a newpath
and associates avalue
to it if possible and returnstrue
. Returnsfalse
if the path already exists or its parent path doesn't exist.int get(string path)
Returns the value associated withpath
or returns-1
if the path doesn't exist.
Example 1:
Example 2:
Constraints:
The number of calls to the two functions is less than or equal to
104
in total.2 <= path.length <= 100
1 <= value <= 109
ac
Last updated