diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 00000000..30cf57ed --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,10 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Ignored default folder with query files +/queries/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/Design-2.iml b/.idea/Design-2.iml new file mode 100644 index 00000000..269e64b8 --- /dev/null +++ b/.idea/Design-2.iml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 00000000..105ce2da --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 00000000..326eb419 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 00000000..45ca9fd1 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 00000000..35eb1ddf --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/hashmap.py b/hashmap.py new file mode 100644 index 00000000..82b082d6 --- /dev/null +++ b/hashmap.py @@ -0,0 +1,27 @@ +class MyHashMap: + + def __init__(self): + self.map = [-1] * (10 ** 6 + 1) + + def put(self, key: int, value: int) -> None: + self.map[key] = value + + def get(self, key: int) -> int: + return self.map[key] + + def remove(self, key: int) -> None: + self.map[key] = -1 + +# Your MyHashMap object will be instantiated and called as such: +# obj = MyHashMap() +# obj.put(key,value) +# param_2 = obj.get(key) +# obj.remove(key) + +# Time complexity +# put O(1) +# get O(1) +# remove O(1) + +#Space Complexity: +# O(10^6) \ No newline at end of file diff --git a/queue_from_stack.py b/queue_from_stack.py new file mode 100644 index 00000000..b3826fe4 --- /dev/null +++ b/queue_from_stack.py @@ -0,0 +1,37 @@ +class MyQueue: + + def __init__(self): + self.inStack = [] + self.outStack = [] + + def push(self, x: int) -> None: + self.inStack.append(x) + + def pop(self) -> int: + self.peek() + return self.outStack.pop() + + def peek(self) -> int: + if not self.outStack: + while self.inStack: + self.outStack.append(self.inStack.pop()) + return self.outStack[-1] + + def empty(self) -> bool: + return not self.inStack and not self.outStack + +# Your MyQueue object will be instantiated and called as such: +# obj = MyQueue() +# obj.push(x) +# param_2 = obj.pop() +# param_3 = obj.peek() +# param_4 = obj.empty() + +# Time complexity: +# push O(1) +# pop O(1) +# peek O(1) +# empty O(1) + +# Space Complexity: +# O(n) \ No newline at end of file