您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

按字母顺序查找最长的子字符串

按字母顺序查找最长的子字符串

尝试更改此:

        if len(set(substr)) != (end - start): # found duplicates or EOS
            break
        if (ord(max(sorted(substr))) - ord(min(sorted(substr))) + 1) == len(substr):

对此:

        if len(substr) != (end - start): # found duplicates or EOS
            break
        if sorted(substr) == list(substr):

这将显示ccl您的示例输入字符串。代码更简单,因为您正试图解决一个更简单的问题:-)

其他 2022/1/1 18:37:50 有486人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶