You can not select more than 25 topics
Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
- #1.11 确定字符串是否包含唯一字符:
- #实现一个算法:识别一个字符串中,是否包含唯一的字符。
- #如果字符串中的字符都是唯一的,则返回 True,如 '123';如果字符串中的字符有重复,则返回 False,如 '1223'。
-
- str = "1223"
- n = len(str)
- #字符列表
- str_list = []
- for i in range(len(str)):
- #字符列表
- if str[i] not in str_list:
- str_list.append(str[i])
- else:
- print('False')
- exit(0)
- print('True')
|