题解 | #在字符串中找出连续最长的数字串#

在字符串中找出连续最长的数字串

https://www.nowcoder.com/practice/2c81f88ecd5a4cc395b5308a99afbbec

import sys

s1=input()

def f1(s):
    di=dict()
    n=len(s)
    so=''
    for i in range(n):
        for j in range(i,n+1):
            if s[i:j].isdigit():
                    di[s[i:j]]=len(s[i:j])
    m=max(di.values())
    for j in di.keys():
        if di[j]==m:
            so=so+j
    print(so,end=',')
    print(m)
f1(s1)

全部评论

相关推荐

点赞 评论 收藏
分享
许愿ssp的咸鱼很不想泡池子:import python as pyhton
点赞 评论 收藏
分享
评论
点赞
1
分享

创作者周榜

更多
牛客网
牛客企业服务