#第一题python解法不知道对不对 ''' 思路 1、将字符长set成集合提取非重复唯一字符 abbbaaccb->abc? 2、滑窗,left由[0,字符结尾减掉不重复的字符] [0,10-3+1] 因为range左开右闭所以要加1 right由[不重复字符,字符尾] [3,10+1] 3、假设res是全字符串[0,len(str1)],每次滑窗后对滑窗字符串进行set后对比,如果长度(right-left)比res小,则替换 ''' str1 = input() only = set(str1) res = [0,len(str1)] for left in range(len(str1)-len(only)+1): for right in range(left+len(only),len(str1)+1): if left>len(str1)-len(only): break if only == set(str1[left:right]): if res[1] > right - left: res = [left,right-left] break print(res) print(res[1],str1[res[0]:res[0]+res[1]])