determine if a string has all unique characters?

前端 未结 16 1428
长发绾君心
长发绾君心 2020-12-28 08:29

Can anybody tell me how to implement a program to check a string contains all unique chars ?

16条回答
  •  春和景丽
    2020-12-28 09:33

    Use a HashTable, add the key for each character along with the count of occurrences as the value. Loop through the HashTable keys to see if you encountered a count > 1. If so, output false.

提交回复
热议问题