题解 | #最长&最短文本#

最长&最短文本

https://www.nowcoder.com/practice/3331d16fe07d4358858178ff5fa73e0d

s = []
while True:
    try:
        s.append(input())
    except:
        s.sort(key=lambda x: len(x))
        min_len = len(s[0])
        max_len = len(s[-1])
        while s and len(s[0]) == min_len:
            print(s.pop(0))
        while s and len(s[-1]) == max_len:
            print(s.pop(-1))
        break

全部评论

相关推荐

评论
1
收藏
分享

创作者周榜

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