Code to verify whether a string has duplicates