[Solved] Find and list duplicates in an unordered array consisting of 10,000,000,00 elements


Here you go

class MyValues{
    public int i = 1;
    private String value = null;

    public MyValues(String v){
        value = v;
    }

    int hashCode()
    {
        return value.length;
    }

    boolean equals(Object obj){
        return obj.equals(value);
    }
}

Now iterate for duplicates

private Set<MyValues> values = new TreeSet<MyValues>();
for(String s : duplicatArray){
    MyValues v = new MyValues(s);
    if (values.add(v))
    {
        v.i++;
    }
}

Time and space are both linear.

6

solved Find and list duplicates in an unordered array consisting of 10,000,000,00 elements