Question
A climate-control dashboard stores each hour’s temperature as a signed deviation from the setpoint, sorted ascending (so it may start negative). The alerting logic needs the squared deviations, also in ascending order. Given the sorted deviations, return their squares sorted ascending in O(n) time — no full re-sort. Hint: the largest square must come from one of the two ends. Example: [-4, -1, 0, 3, 10] gives [0, 1, 9, 16, 100].
sorted_squared_deviations(devs: list[int]) → list[int][[-4,-1,0,3,10]]out[0,1,9,16,100]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.
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.