determine if a string has all unique characters?

前端 未结 16 1429
长发绾君心
长发绾君心 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:26

    Use a 256-entry array. Fill it with 0. Now traverse the string setting the corresponding entry in the array to 1 if it's 0. Otherwise, there are repeated chars in the string.

提交回复
热议问题