题解 | #字符串排序#

字符串排序

https://www.nowcoder.com/practice/5190a1db6f4f4ddb92fd9c365c944584

# 2024年10月19日   下午18:35


# A Famous Saying: Much Ado About Nothing (2012/8).
# A aaAAbc dFgghh: iimM nNn oooos Sttuuuy (2012/8).

s = input()
a = ''
for i in s:
    if i.isalpha():
        a += i
#print(a)
b = sorted(a,key=str.upper)
#print(*b)
res = ''
idx = 0
for i in range(len(s)):
    if s[i].isalpha():
        res += b[idx]
        idx += 1
    else:
        res += s[i]
print(''.join(res))

全部评论

相关推荐

点赞 评论 收藏
分享
牛客刘北:如果暑期实习是27届的话,你要晚一年才会毕业,企业为什么会等你呢?要搞清时间逻辑呀!27届现在实习只能是在暑假实习,这是日常实习,不是暑期实习。所以多去投日常实习吧,暑期实习肯定不会要你的
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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