Algorithm: efficient way to remove duplicate integers from an array

前端 未结 30 2236
离开以前
离开以前 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:23

    If you are allowed to use C++, a call to std::sort followed by a call to std::unique will give you the answer. The time complexity is O(N log N) for the sort and O(N) for the unique traversal.

    And if C++ is off the table there isn't anything that keeps these same algorithms from being written in C.

提交回复
热议问题