码迷,mamicode.com
首页 > 其他好文 > 详细

面试题-求最大字典区间

时间:2018-10-25 00:12:58      阅读:193      评论:0      收藏:0      [点我收藏+]

标签:input   exe   strip   span   输入   conda   ini   exit   NPU   

 

给定一组字符串,求最大字典区间

string=list(input().strip())
target=[]
Max=0
for i in range(len(string)-1, -1, -1):
    ch=string[i]
    if ch >=Max:
        target.append(ch)
        Max=ch
target.reverse()
print("".join(target))
t=(1,2)
print(t)

输入输出

E:\Anaconda\python.exe F:/pycharmprogram/test/test1.py
ACDBBCDACB
DDCB

Process finished with exit code 0

 

面试题-求最大字典区间

标签:input   exe   strip   span   输入   conda   ini   exit   NPU   

原文地址:https://www.cnblogs.com/tsdblogs/p/9846506.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!