题解 | #子串计算#Python版代码

子串计算

https://www.nowcoder.com/practice/bcad754c91a54994be31a239996e7c11

from collections import Counter
s = input()
counter = Counter(s[i:j] for i in range(len(s)) for j in range(i + 1, len(s) + 1))
for num, count in sorted(counter.items()):
    if (count > 1): print(num, count)

全部评论

相关推荐

ros275229:社团删了吧,cf因该1200才勉强入门吧,也删了,你可以写算法刷了多少道,都比这个好
点赞 评论 收藏
分享
脑袋锈住了:你这算啥,哥们中科院中强所硕士,本科211,叫我去干分拣,时薪20
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务