Question
Given a list of integers, a target value, and an integer k (1 <= k <= length of the list), return the k-th largest absolute deviation from the target. The absolute deviation of an element x is |x - target|. Deviations from different elements may be equal; each element contributes one deviation and duplicates are counted separately. Example: nums = [100, 140, 90, 110], target = 120, k = 2 gives 20 — the deviations are [20, 20, 30, 10], and arranged largest-first they read 30, 20, 20, 10.
kth_deviation(nums: list[int], target: int, k: int) → int[[100,140,90,110],120,2]out20State 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.
Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.