DEV Community


Discussion on: Google Javascript Interview Question - Remove Duplicates from Sorted Array

theodesp profile image
Theofanis Despoudis

Based on the code you've given:

nums.sort(): Is O(nlogn) where n = size of original array. Because array is already sorted then you don't need to sort again anyway.

You can also use a Map to keep track of already seen items.

The example shows integers but the problem statement does not mention any restrictions on the types. Will this work on any type?