Compact Sorted Values
Keep one copy of each value in a sorted list with a read pointer and a write pointer.
The problem
Implement compact_sorted_values(values). values is sorted in non-decreasing order and may be empty. Return a new list that contains each distinct value once, in the same order. Do not use a set or a dictionary, and do not change the input list.
Starter code
def compact_sorted_values(values):
passPublic examples
values = [1, 1, 2, 2, 2, 4]gives[1, 2, 4]values = [1, 3, 5]gives[1, 3, 5]
Solving it in the practice book needs an active paid plan.
Open it in the practice bookOne thought at a time.
