Array remove duplicate elements

前端 未结 12 1585
陌清茗
陌清茗 2020-11-27 16:17

I have an unsorted array, what is the best method to remove all the duplicates of an element if present?

e.g:

a[1,5,2,6,8,9,1,1,10,3,2,4,1,3,11,3]
         


        
12条回答
  •  北荒
    北荒 (楼主)
    2020-11-27 16:43

    Time O(n) space O(n) 
    
    #include 
        #include
        using namespace std;
        void fun(int arr[],int size){
    
            int count=0;
            int has[100]={0};
            for(int i=0;i

提交回复
热议问题