From 0e0f01c379d6b828e715ced4368183e0af05ea6e Mon Sep 17 00:00:00 2001 From: nupurvavhal <194372227+nupurvavhal@users.noreply.github.com> Date: Tue, 10 Feb 2026 10:51:21 +0000 Subject: [PATCH 1/3] task: Add type hints to inversions.py --- divide_and_conquer/inversions.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/divide_and_conquer/inversions.py b/divide_and_conquer/inversions.py index 35f78fe5cf1e..79dafb005f90 100644 --- a/divide_and_conquer/inversions.py +++ b/divide_and_conquer/inversions.py @@ -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 @@ -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 @@ -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 @@ -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: From b4a6c843d6f7fcee8aab465afcbc1cd0e34af1e8 Mon Sep 17 00:00:00 2001 From: nupurvavhal <194372227+nupurvavhal@users.noreply.github.com> Date: Tue, 10 Feb 2026 11:04:41 +0000 Subject: [PATCH 2/3] fixed formatting error --- divide_and_conquer/inversions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/divide_and_conquer/inversions.py b/divide_and_conquer/inversions.py index 79dafb005f90..6fe1fd9c7cb7 100644 --- a/divide_and_conquer/inversions.py +++ b/divide_and_conquer/inversions.py @@ -118,7 +118,7 @@ def _count_cross_inversions(p: list[int], q: list[int]) -> tuple[list[int], int] return r, num_inversion -def main()-> None: +def main() -> None: arr_1 = [10, 2, 1, 5, 5, 2, 11] # this arr has 8 inversions: From d6a1505a790d7a204fb8ae01ed15665cbb079a5c Mon Sep 17 00:00:00 2001 From: NupurV <194372227+nupurvavhal@users.noreply.github.com> Date: Tue, 10 Feb 2026 16:53:43 +0530 Subject: [PATCH 3/3] style: Fix RUF037 in hash_table_with_linked_list --- data_structures/hashing/hash_table_with_linked_list.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data_structures/hashing/hash_table_with_linked_list.py b/data_structures/hashing/hash_table_with_linked_list.py index f404c5251246..c8dffa30b8e8 100644 --- a/data_structures/hashing/hash_table_with_linked_list.py +++ b/data_structures/hashing/hash_table_with_linked_list.py @@ -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]