Remove duplicate heart rates
A heart-rate monitor emits one reading per second, and the values arrive sorted for a post-workout report. Consecutive seconds often repeat the same value, and the report only needs each distinct rate once. Given the sorted list rates, return the distinct values in the same order using a read pointer and a write pointer in one pass — no set or extra map. Example: [60, 60, 62, 65, 65, 65, 70] becomes [60, 62, 65, 70].
Implement
unique_sorted_rates(rates: list[int]) → list[int]Examples
in
[[60,60,62,65,65,65,70]]out[60,62,65,70]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 11 min
solution.py
InputExpectedGot
[[60,60,62,65,65,65,70]][60,62,65,70]not run yetsample