Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
neha3423
  • Loading branch information
neha3423 committed Oct 23, 2023
commit f750a7ec2b415125bcbcae69172b113e04ffbd00
15 changes: 7 additions & 8 deletions data_structures/arrays/kth_largest_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,17 @@ def kth_largest_element(arr: list[int], position: int) -> int:
>>> kth_largest_element([2, 5, 6, 1, 9, 3, 8, 4, 7, 3, 5], 1)
9
>>> kth_largest_element([2, 5, 6, 1, 9, 3, 8, 4, 7, 3, 5], -2)
"Exception raised:
Traceback (most recent call last):
...
ValueError: Invalid value of 'position'"
ValueError: Invalid value of 'position'
>>> kth_largest_element([9, 1, 3, 6, 7, 9, 8, 4, 2, 4, 9], 110)
"Traceback (most recent call last):
Traceback (most recent call last):
...
ValueError: Invalid value of 'position'"
ValueError: Invalid value of 'position'
>>> kth_largest_element([1, 2, 4, 3, 5, 9, 7, 6, 5, 9, 3], 0)
"Traceback (most recent call last):
Traceback (most recent call last):
...
ValueError: Invalid value of 'position'"
ValueError: Invalid value of 'position'
>>> kth_largest_element(['apple', 'cherry', 'date','banana'], 2)
'cherry'
>>> kth_largest_element([3.1, 1.2, 5.6, 4.7,7.9,5,0], 2)
Expand All @@ -79,9 +78,9 @@ def kth_largest_element(arr: list[int], position: int) -> int:
>>> kth_largest_element([], 1)
-1
>>> kth_largest_element([3.1, 1.2, 5.6, 4.7,7.9,5,0], 1.5)
"Traceback (most recent call last):
Traceback (most recent call last):
...
ValueError: The position should be an integer"
ValueError: The position should be an integer
"""
if not arr:
return -1
Expand Down