Skip to content
Open
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
7 changes: 3 additions & 4 deletions data_structures/arrays/kth_largest_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,19 +99,18 @@
raise ValueError("Invalid value of 'position'")
low, high = 0, len(arr) - 1
while low <= high:
if low > len(arr) - 1 or high < 0:
return -1
pivot_index = partition(arr, low, high)
if pivot_index == position - 1:
target_index = position - 1

Check failure on line 103 in data_structures/arrays/kth_largest_element.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (invalid-syntax)

data_structures/arrays/kth_largest_element.py:103:1: invalid-syntax: Unexpected indentation
if pivot_index == target_index:
return arr[pivot_index]
elif pivot_index > position - 1:
elif pivot_index > target_index:
high = pivot_index - 1
else:
low = pivot_index + 1
return -1


if __name__ == "__main__":

Check failure on line 113 in data_structures/arrays/kth_largest_element.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (invalid-syntax)

data_structures/arrays/kth_largest_element.py:113:1: invalid-syntax: Expected a statement
import doctest

doctest.testmod()
Loading