delete duplicates in O(n^2)