Question
A fitness band streams non-negative sensor readings, but a failed sample is recorded as -1. Given the readings list, remove every failed sample while keeping the valid readings in their original order, and return the compacted list. Do it in a single pass using a write pointer (overwrite the array in place, then cut it to length) rather than building a filtered copy per element check. Example: [7, -1, 8, -1, -1, 9] becomes [7, 8, 9].
compact_readings(readings: list[int]) → list[int][[7,-1,8,-1,-1,9]]out[7,8,9]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.