Apple Interview Question

Remove duplicates with best time complexity