K-th lowest distinct level
A sensor logs the water level of a storage tank once per hour, in centimeters. Levels often repeat across readings. Given the list of readings and an integer k, return the k-th lowest distinct level — duplicates collapse to a single entry before counting. You may assume k is at least 1 and no larger than the number of distinct levels. Example: levels = [40, 10, 10, 25], k = 2 gives 25, because the distinct levels in increasing order are 10, 25, 40.
Implement
kth_lowest_level(levels: list[int], k: int) → intExamples
in
[[40,10,10,25],2]out25What a strong answer looks like
State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
0:00 of about 12 min
solution.py
InputExpectedGot
[[40,10,10,25],2]25not run yetsample