Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion data_structures/hashing/hash_table_with_linked_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

def _set_value(self, key, data):
self.values[key] = deque([]) if self.values[key] is None else self.values[key]
self.values[key] = deque() if self.values[key] is None else self.values[key]
self.values[key].appendleft(data)
self._keys[key] = self.values[key]

Expand Down
8 changes: 4 additions & 4 deletions divide_and_conquer/inversions.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"""


def count_inversions_bf(arr):
def count_inversions_bf(arr: list[int]) -> int:
"""
Counts the number of inversions using a naive brute-force algorithm
Parameters
Expand Down Expand Up @@ -40,7 +40,7 @@ def count_inversions_bf(arr):
return num_inversions


def count_inversions_recursive(arr):
def count_inversions_recursive(arr: list[int]) -> tuple[list[int], int]:
"""
Counts the number of inversions using a divide-and-conquer algorithm
Parameters
Expand Down Expand Up @@ -74,7 +74,7 @@ def count_inversions_recursive(arr):
return c, num_inversions


def _count_cross_inversions(p, q):
def _count_cross_inversions(p: list[int], q: list[int]) -> tuple[list[int], int]:
"""
Counts the inversions across two sorted arrays.
And combine the two arrays into one sorted array
Expand Down Expand Up @@ -118,7 +118,7 @@ def _count_cross_inversions(p, q):
return r, num_inversion


def main():
def main() -> None:
arr_1 = [10, 2, 1, 5, 5, 2, 11]

# this arr has 8 inversions:
Expand Down