Code RoomZ-score standardization
MediumPrep Room Coding #1544

Z-score standardization

CodingML systemsEntry–Mid~18 min

Z-score standardize a non-empty list of numbers: each value becomes (x - mean) / std, where std is the population standard deviation (divide the variance by n, not n-1). If the standard deviation is zero (all values equal), return a list of all 0.0. Round each output to 6 decimal places.

Implement
zscore_normalize(xs: list[float]) → list[float]
Examples
in[[1,2,3]]out[-1.224745,0,1.224745]
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 18 min
InputExpectedGot
[[1,2,3]][-1.224745,0,1.224745]not run yetsample