K-th lowest distinct level
Your task
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.
Examples
kth_lowest_level(levels: list[int], k: int) -> intExample 1
Input
kth_lowest_level([40, 10, 10, 25], 2)Output
25