How to efficiently remove duplicates from an array without using Set

后端 未结 30 2835
情深已故
情深已故 2020-11-22 07:29

I was asked to write my own implementation to remove duplicated values in an array. Here is what I have created. But after tests with 1,000,000 elements it took very long ti

30条回答
  •  不知归路
    2020-11-22 07:55

    public void removeDup(){ 
    String[] arr = {"1","1","2","3","3"};
              boolean exists = false;
              String[] arr2 = new String[arr.length];
              int count1 = 0;
              for(int loop=0;loop

提交回复
热议问题