Skip to content

Commit a3309ef

Browse files
nupurvavhalcclauss
andauthored
task: Add type hints to inversions.py (#14262)
* task: Add type hints to inversions.py * fixed formatting error * style: Fix RUF037 in hash_table_with_linked_list * Initialize deque with empty list for None values --------- Co-authored-by: Christian Clauss <cclauss@me.com>
1 parent b93bcc3 commit a3309ef

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

‎divide_and_conquer/inversions.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"""
1010

1111

12-
def count_inversions_bf(arr):
12+
def count_inversions_bf(arr: list[int]) -> int:
1313
"""
1414
Counts the number of inversions using a naive brute-force algorithm
1515
Parameters
@@ -40,7 +40,7 @@ def count_inversions_bf(arr):
4040
return num_inversions
4141

4242

43-
def count_inversions_recursive(arr):
43+
def count_inversions_recursive(arr: list[int]) -> tuple[list[int], int]:
4444
"""
4545
Counts the number of inversions using a divide-and-conquer algorithm
4646
Parameters
@@ -74,7 +74,7 @@ def count_inversions_recursive(arr):
7474
return c, num_inversions
7575

7676

77-
def _count_cross_inversions(p, q):
77+
def _count_cross_inversions(p: list[int], q: list[int]) -> tuple[list[int], int]:
7878
"""
7979
Counts the inversions across two sorted arrays.
8080
And combine the two arrays into one sorted array

0 commit comments

Comments
 (0)