Algorithm: efficient way to remove duplicate integers from an array

前端 未结 30 2748
离开以前
离开以前 2020-11-22 16:03

I got this problem from an interview with Microsoft.

Given an array of random integers, write an algorithm in C that removes duplicated numbers an

30条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-22 16:35

    Insert all the elements in a binary tree the disregards duplicates - O(nlog(n)). Then extract all of them back in the array by doing a traversal - O(n). I am assuming that you don't need order preservation.

提交回复
热议问题