How does one remove duplicate elements in place in an array in O(n) in C or C++?

后端 未结 7 1744
长情又很酷
长情又很酷 2020-12-16 21:43

Is there any method to remove the duplicate elements in an array in place in C/C++ in O(n)? Suppose elements are a[5]={1,2,2,3,4} then resulting array should c

7条回答
  •  孤城傲影
    2020-12-16 22:19

    The example you have given is a sorted array. It is possible only in that case (given your constant space constraint)

提交回复
热议问题