Code Room
CodingHardcod-g987
Subject Ml algorithmsLevel Senior–Staff~30 minCommon in ML systems interviewsIndustries Software development, Technology

Question

Perform one full-batch gradient-descent update step for simple linear regression y = w*x + b under mean-squared error. Given parallel lists xs and ys (n>=1 points), current weight w, bias b, and learning rate lr, compute predictions p_i = w*x_i + b, the error e_i = p_i - y_i, the gradients dw = (2/n)*sum(e_i*x_i) and db = (2/n)*sum(e_i), then return the updated parameters [w - lr*dw, b - lr*db]. Round each returned parameter to 6 decimal places.

Implement
gd_step(xs: list[float], ys: list[float], w: float, b: float, lr: float) → list[float]
Examples
in[[1,2],[2,4],0,0,0.1]out[1,0.6]
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.

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.

Run or narrate your approach, then ask the coach.