How to remove duplicates from a list using an auxiliary array in Java?

前端 未结 8 781
南方客
南方客 2020-12-10 19:44

I am trying to remove duplicates from a list by creating a temporary array that stores the indices of where the duplicates are, and then copies off the original array into a

8条回答
  •  北荒
    北荒 (楼主)
    2020-12-10 20:19

    Here's another alternative without the use of sets, only primitive types:

    public static double [] removeDuplicates(double arr[]) {
        double [] tempa = new double[arr.length];
        int uniqueCount = 0;
        for (int i=0;i

    It does require a temporary array of double objects on the way towards getting your actual result.

提交回复
热议问题