Code RoomDrop readings that never arrived
EasyPrep Room Coding #5036

Drop readings that never arrived

CodingAlgorithms & data structuresEntry–Mid~7 min

Given `readings` with columns `device`, `ts` and `reading`, drop the rows whose `reading` is missing. Return `device`, `ts` and `reading`, sorted by `device` ascending and then `ts` ascending.

Implement
drop_missing(readings: dataframe) → dataframe
Examples
in[{"__df__":[{"ts":"2024-05-01","device":"a1","reading":20.5},{"ts":"2024-05-02","device":"a1","reading":null},{"ts":"2024-05-03","device":"a1","reading":22.5},{"ts":"2024-05-01","device":"b2","reading":null},{"ts":"2024-05-02","device":"b2","reading":31},{"ts":"2024-05-03","device":"b2","reading":33}]}]out[{"ts":"2024-05-01","device":"a1","reading":20.5},{"ts":"2024-05-03","device":"a1","reading":22.5},{"ts":"2024-05-02","device":"b2","reading":31},{"ts":"2024-05-03","device":"b2","reading":33}]
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 7 min
InputExpectedGot
[{"__df__":[{"ts":"2024-05-01","device":"a1","reading":20.5},{"ts":"2024-05-02","device":"a1","reading":null},{"ts":"2024-05-03","device":"a1","reading":22.5},{"ts":"2024-05-01","device":"b2","reading":null},{"ts":"2024-05-02","device":"b2","reading":31},{"ts":"2024-05-03","device":"b2","reading":33}]}][{"ts":"2024-05-01","device":"a1","reading":20.5},{"ts":"2024-05-03","device":"a1","reading":22.5},{"ts":"2024-05-02","device":"b2","reading":31},{"ts":"2024-05-03","device":"b2","reading":33}]not run yetsample