delete duplicates in n time