Removing Duplicates in an array in C

前端 未结 5 1406
醉酒成梦
醉酒成梦 2020-12-20 08:09

The question is a little complex. The problem here is to get rid of duplicates and save the unique elements of array into another array with their original sequence.

5条回答
  •  囚心锁ツ
    2020-12-20 08:22

    1. Traverse through the items in the array - O(n) operation
    2. For each item, add it to another sorted-array
    3. Before adding it to the sorted array, check if the entry already exists - O(log n) operation

    Finally, O(n log n) operation

提交回复
热议问题