本文主要是介绍【笔试题目】58同城2020秋招测试开发,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
题目描述
输入单词,如head,apple,middle,end,hard
统计出e或d字母结尾的单词
打印结果
{head=1, apple=1, middle=1, end=1, hard=1}
line = raw_input('')
values = line.split(',')
dict1={}
list1=[]
for i in values:if (i[-1]=='d'or i[-1]=='e') and i not in dict1.keys():dict1[i] = 1list1.append(i)elif (i[-1]=='d'or i[-1]=='e') and i in dict1.keys():dict1[i] += 1str1=''for i in list1:str1+='%s=%d, '% (i,dict1[i])
str2='{'+str1[:-2]+'}'
print str2
测试用例通过20%
题目描述2
找出重叠的字符串
如输入aabaabb
重叠的字符串有 aa aa bb
打印结果
a:4
b:2
str1=raw_input('')dict1={}
list1=[]index=0
temp_num=0
for i in str1:if index<len(str1)-1:if i not in dict1.keys() and str1[index+1]==i :dict1[i] = 1index+=1elif i in dict1.keys() and str1[index+1]==i :dict1[i] += 1index += 1elif i in dict1.keys() and str1[index-1]==i :dict1[i] += 1index += 1else:index += 1else:if i in dict1.keys() and str1[index - 1] == i:dict1[i] += 1# print dict1.iteritems()
dict2 = sorted(dict1.iteritems(), key=lambda d: d[1],reverse = True)for x in dict2:if x[1]>1:print x[0]+':'+str(x[1])
这篇关于【笔试题目】58同城2020秋招测试开发的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!