Skip to content

Commit 2bc9925

Browse files
committed
Add missing type annotations
1 parent 1536125 commit 2bc9925

File tree

6 files changed

+16
-14
lines changed

6 files changed

+16
-14
lines changed

01. Arrays/01-01 Anagram Check/anagram.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
from typing import Dict
2+
3+
14
# Cheating
25
def anagram2(s1: str, s2: str) -> bool:
36
string1 = "".join(sorted(s1.lower())).strip()
@@ -11,7 +14,7 @@ def anagram(s1: str, s2: str) -> bool:
1114
s2 = s2.lower().replace(" ", "")
1215

1316
# create map of characters in first string
14-
char_map = {}
17+
char_map: Dict[str, int] = {}
1518

1619
for char in s1:
1720
char_map.setdefault(char, 0)

01. Arrays/01-03 Find the Missing Element/finder.py

-1
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,3 @@ def finder2(arr1, arr2):
2828
result ^= num
2929

3030
return result
31-

02. Stacks, Queues and Deques/02-01 Implement a Stack/stack.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
from typing import Any
1+
from typing import Any, List
22

33

44
class Stack(object):
55
def __init__(self) -> None:
6-
self.items = []
6+
self.items: List[Any] = []
77

88
def push(self, item: Any) -> None:
99
# Push a new item

02. Stacks, Queues and Deques/02-02 Implement a Queue/queue.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
from typing import Any
1+
from typing import Any, List
22

33

44
class Queue(object):
5-
def __init__(self):
6-
self.items = []
5+
def __init__(self) -> None:
6+
self.items: List[Any] = []
77

88
def size(self) -> int:
99
# Returns the size of the Queue

02. Stacks, Queues and Deques/02-03 Implement a Deque/deque.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
from typing import Any
1+
from typing import Any, List
22

33

44
class Deque(object):
55
def __init__(self) -> None:
6-
self.items = []
6+
self.items: List[Any] = []
77

88
def size(self) -> int:
99
# Checks the Size

02. Stacks, Queues and Deques/02-05 Implement a Queue Using Two Stacks/queue_2_stacks.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
from typing import Any
1+
from typing import Any, List
22

33

44
class Queue2Stacks(object):
55
def __init__(self) -> None:
6-
self.inbox = []
7-
self.outbox = []
6+
self.inbox: List[Any] = []
7+
self.outbox: List[Any] = []
88

99
def enqueue(self, element: Any) -> None:
1010
# push new element onto inbox
1111
self.inbox.append(element)
1212

1313
def dequeue(self) -> Any:
14-
# If outbox is empty, refill it by popping each element from inbox and pushing it
15-
# onto outbox. Pop and return the top element from outbox
14+
# If outbox is empty, refill it by popping each element from inbox and
15+
# pushing it onto outbox. Pop and return the top element from outbox
1616
if len(self.outbox) == 0:
1717
while len(self.inbox) != 0:
1818
self.outbox.append(self.inbox.pop())

0 commit comments

Comments
 (0)