题解 | #字符串加密#

字符串加密

https://www.nowcoder.com/practice/e4af1fe682b54459b2a211df91a91cf3

import sys

inp = sys.stdin.readlines()
key = inp[0].strip()
s = inp[1].strip()

new_key = ''
se = set()
for c in key:
    if c not in se:
        new_key += c
        se.add(c)

for c in 'abcdefghijklmnopqrstuvwxyz':
    if c not in new_key:
        new_key += c

res = ''
for c in s:
    index = ord(c)-ord('a')
    res += new_key[index]
print(res)

全部评论

相关推荐

点赞 评论 收藏
转发
点赞 收藏 评论
分享
牛客网
牛客企业服务