东方财富后端开发-4月4日笔经
回馈下牛客,春招尾端佛系做题,积点人品。
单选 . 多选 .填空 ->50 分
编程两题 ->50 分
1.找出不重複字符串子串各数 ex: abc -> 6个
example = 'abc' S = [i for i in example] def DO(s): num = len(s) res =[] for i in range(2**num): Str ='' for j in range(num): if(i >> j ) % 2 == 1: Str +=s[j] res.append(Str) return res res = [] for e in DO(S): if e != '': if e in a : if e not in res: res.append(e) print(res)
2.两个字符串 M & N 合并排序 ex: M-> 1 2 3 -4 5 15 N-> 2 5 7 4 6 -> -4 1 2 2 3 4 5 5 6 7 15
M = '1 2 3 -4 5 15 ' N = '2 5 7 4 6 ' res = M+N res1=sorted(res.split(' ')) ans = [] for i in res1: if i != ' ': try: ans.append(int(i)) except : pass a = '' for i in sorted(ans): a+=('{} '.format(i)) print(a)