Code Room
CodingMedium
Question
Implement a numerically stable softmax over a non-empty list of real-valued logits. Softmax(x)_i = exp(x_i) / sum_j exp(x_j). To avoid overflow on large logits, subtract the maximum logit from every element before exponentiating (this does not change the result mathematically). Return the list of probabilities, each rounded to 6 decimal places.
Implement
softmax(logits: list[float]) → list[float]Examples
in
[[0,0]]out[0.5,0.5]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.
Learn the concepts
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.