题解 | #字符串排序#

字符串排序

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

#进行了深拷贝
import sys
import copy

lines=sys.stdin.readlines()
l=list(lines[0])
fz=[]
for i in range(len(l)):
    if l[i].isalpha():
        fz.append(l[i])
        l[i]="pending"


old=copy.deepcopy(fz)
# print(old)

for i in range(len(fz)):
    for j in range(i+1,len(fz)):
        if fz[i].upper()>fz[j].upper() :
            fz[i],fz[j]=fz[j],fz[i]


for item in fz:
    for i in range(len(l)):
        if l[i]=='pending':
            l[i]=item
            break

for i in range(len(l)):
    for j in range(len(old)):
        if l[i].upper()==old[j].upper():
            l[i]=old[j]
            old.remove(old[j])
            break
result=""
for item in l:
    result=result+item

print(result)

全部评论

相关推荐

🎓学历背景:双非土木硕👨‍💻意向职位:AI应用开发大佬们可以帮我看看简历吗,秋招至今0offer
秋招结束再玩瓦:今年科班都不好找哇……你可以试试交叉岗,比如制造业国企的一些开发算法,或者互联网的边缘岗,it技术支持,运维这些
我的简历长这样
点赞 评论 收藏
分享
双尔:反手回一个很抱歉,经过慎重考虑,您与我的预期暂不匹配,感谢您的投递
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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