Run-length encoding codec
Implement run-length encoding for a columnar store. Given a list of integer values (a column), produce a compact encoding as a list of [value, count] pairs where consecutive equal values are collapsed into one run. Then, to prove the codec round-trips, DECODE that encoding back into the original list and return the decoded list. The function must return the decoded list (which should equal the input). Input length <= 10^5.
Implement
rle_roundtrip(values: list[int]) → list[int]Examples
in
[[1,1,1,2,2,3]]out[1,1,1,2,2,3]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 20 min
solution.py
InputExpectedGot
[[1,1,1,2,2,3]][1,1,1,2,2,3]not run yetsample