Remove duplicate heart rates

Write codeEasy11 min

Your task

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].

Examples

unique_sorted_rates(rates: list[int]) -> list[int]
Example 1
Inputunique_sorted_rates([60, 60, 62, 65, 65, 65, 70])
Output[60, 62, 65, 70]