Answers for "string hashset"

0

hashset

/*
 * Template for using hash set to find duplicates.
 */
boolean findDuplicates(List<Type> keys) {
    // Replace Type with actual type of your key
    Set<Type> hashset = new HashSet<>();
    for (Type key : keys) {
        if (hashset.contains(key)) {
            return true;
        }
        hashset.add(key);
    }
    return false;
}
Posted by: Guest on April-06-2022

Browse Popular Code Answers by Language