Zero out duplicates and sort an array | Apple Interview Question