You have an array\list of elements that is already sorted. Consider a sample as follows.
[0, 1, 1, 1, 2, 2, …, 231, …, 4097, 4097]
You can clearly see that we have duplicates in the above array.
Your task is to write the most efficient code which can remove these duplicates.
Do not use high level utilities, libraries or functions like set(…)
Sample run:
nums = [0, 0, 1, 1, 1, 2, 3, 4, 5, 5]
# your code here
print(nums)
[0, 1, 2, 3, 4, 5]
”’