We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1d38742 commit b6ceb68Copy full SHA for b6ceb68
Python/design-file-system.py
@@ -0,0 +1,28 @@
1
+# Time: create: O(n)
2
+# get: O(n)
3
+# Space: O(n)
4
+
5
+class FileSystem(object):
6
7
+ def __init__(self):
8
+ self.__lookup = {"": -1}
9
10
+ def create(self, path, value):
11
+ """
12
+ :type path: str
13
+ :type value: int
14
+ :rtype: bool
15
16
+ if path[:path.rfind('/')] not in self.__lookup:
17
+ return False
18
+ self.__lookup[path] = value
19
+ return True
20
21
+ def get(self, path):
22
23
24
+ :rtype: int
25
26
+ if path not in self.__lookup:
27
+ return -1
28
+ return self.__lookup[path]
0 commit comments