[Facebook data engineer coding interview] remove duplicates from an array/list

Data Science Interview QuestionsCategory: Data Engineer Coding[Facebook data engineer coding interview] remove duplicates from an array/list
Pythin asked 2 months ago

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]

”’


[Content Sponsor #1] Start learning through a free trial on Datacamp!
[Content Sponsor #2] $750 discount on any springboard courses including Data Science Career Track which comes with a Job Guarantee!

Your Answer

7 + 2 =

Data Science Career Bootcamp