Apple interview question

Remove duplicates with best time complexity