题解 | 提取不重复的整数

提取不重复的整数

https://www.nowcoder.com/practice/253986e66d114d378ae8de2e6c4577c1

n = input()  # 接收输入集
n = n[::-1]  # 将输入的字符串进行倒序
opt = ''  # 创建空字符串准备接受结果数据
for i in n:  # 循环遍历已倒序的字符串
    if i not in opt:  # 判断每一个字符是否存在
        opt += i  # 如果不存在则添加进结果
print(int(opt))  # 将结果字符串转换为整数然后打印输出


全部评论

相关推荐

评论
1
收藏
分享

创作者周榜

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