思路
- 把长字符串放入set;
- 遍历短字符串,查看每个字符是否在以上的set中,如果在,counter+1,否则跳过;
- 最后比较counter和短字符串的长度是否一致。
代码
while True: try: s1 = input() s2 = input() b = set(s2) k = 0 for c in s1: if c in b: k += 1 if k==len(s1): print("true") else: print("false") except: break
while True: try: s1 = input() s2 = input() b = set(s2) k = 0 for c in s1: if c in b: k += 1 if k==len(s1): print("true") else: print("false") except: break