Removing Duplicates in an array in C

前端 未结 5 1424
醉酒成梦
醉酒成梦 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:26

    i think that in C you can create a second array. then you copy the element from the original array only if this element is not already in the send array. this also preserve the order of the element.

    if you read the element one by one you can discard the element before insert in the original array, this could speedup the process.

提交回复
热议问题