Code RoomSort squared deviations
EasyPrep Room Coding #601

Sort squared deviations

CodingAlgorithms & data structuresEntry–Mid~12 min

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].

Implement
sorted_squared_deviations(devs: list[int]) → list[int]
Examples
in[[-4,-1,0,3,10]]out[0,1,9,16,100]
What 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
InputExpectedGot
[[-4,-1,0,3,10]][0,1,9,16,100]not run yetsample