Code RoomStrip sensor padding zeros
EasyPrep Room Coding #617

Strip sensor padding zeros

CodingAlgorithms & data structuresEntry–Mid~10 min

A vibration sensor pads its log with zeros while it spins up and winds down, so a capture looks like [0, 0, 4, 0, 5, 0]. Given the readings, strip the leading zeros and the trailing zeros but keep any zeros in the middle (they are genuine readings), and return what remains. Move one pointer in from each end. An all-zero or empty log returns an empty list. Example above returns [4, 0, 5].

Implement
trim_zero_padding(readings: list[int]) → list[int]
Examples
in[[0,0,4,0,5,0]]out[4,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.

0:00 of about 10 min
InputExpectedGot
[[0,0,4,0,5,0]][4,0,5]not run yetsample