educative.io

If k =0 or there are duplicates in test_list

test_dict=dict()

for item in test_list:
test_dict[item]=0

sorted_list =sorted(test_dict.keys(), reverse=True)
if k==0:
kth_max=None
else:
kth_max=sorted_list[k-1]


Type your question above this line.

Course: https://www.educative.io/collection/10370001/5473789393502208
Lesson: https://www.educative.io/collection/page/10370001/5473789393502208/5150232864096256

Hi @Tatenda_Zhou

For

It will return the minimum value, and as far as the duplicate values go, yes your solution is correct. Still, you have to remove reverse=True from sorted() because that will sort the list in descending order, and your algorithm will start to work for the kth minimum value.