Code Room
CodingEasycod-g1420
Subject Two pointersLevel Entry–Mid~10 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

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.

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.