求助!!面试题:找出相似结构的字符串

问题:N个字符串,例如字符串earnestnessbiophysicalohax和agekestnessbiophysicalohax规则是前四位字符不同,后面字符相同
找出所有这种结构的相似字符串并输出。

输入:
[earnestnessbiophysicalohax
,agekestnessbiophysicalohax
,hjbtestnessbiophysicalohax
,0defd57ebfef34be
,ztix4c82bcf6b01
,a8004c82bcf6b01
,werk4c82bcf6b01
,ddb2a7a2e3c603cc14
,ddb2a7a2e37ebf7ebfq]

输出:
[earnestnessbiophysicalohax
,agekestnessbiophysicalohax
,hjbtestnessbiophysicalohax
,a8004c82bcf6b01
,werk4c82bcf6b01]

哪位大佬可以帮忙解答下,感谢(最好用Python,java也可以)。


#笔试题目##春招#
全部评论
把除去前四位之后剩下的作为基元用map统计,然后再遍历一遍map,如果size>=2说明有两个符合题意的字符串且基元是一样的,统计完全即可
点赞 回复
分享
发布于 2019-04-12 13:18

相关推荐

头像
04-09 14:29
Java
点赞 评论 收藏
转发
点赞 收藏 评论
分享
牛客网
牛客企业服务