题解 | #提取不重复的整数#
提取不重复的整数
https://www.nowcoder.com/practice/253986e66d114d378ae8de2e6c4577c1
import sys
n = int(input())
res = []
ls = list(map(int, str(n))) # 取出整数的每一位
ls = ls[::-1] #用切片翻转
for item in ls: #用新列表去重
if item not in res:
res.append(item)
# 将新列表合成字符串再转为整数
print(int(''.join(str(i) for i in res)))
查看6道真题和解析