题解 | #字符串加密#
字符串加密
http://www.nowcoder.com/practice/e4af1fe682b54459b2a211df91a91cf3
刚开始想用set去重,但是忘了set会打乱顺序,所以怎么都不对。改成笨方法for循环就行了。 43ms 4668kb
lst=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
key=list(input())
mi=list(input())
lst_key=[]
for i in key:
if i not in lst_key:
lst_key.append(i)
mi=list(map(lst.index, mi))
for i in key[::-1]:
lst.remove(i)
lst.insert(0, i)
for j in mi:
print(lst[j],end='')