给出一系列数
找出出现次数最少的,打出,并且打出他的位置
如果是同样次数最少的数,打出他的最先出现的哪个
:提示用字典,时间复杂度更小
i=0
dt={}
while True:
try:
n=int(input())
if n not in dt:
dt[n]=[1,i]
else:
dt[n][0] += 1
i +=1
except:
break
print(dt)
POS =100000
min=100000
ans=0
for x in dt.items():
if x[1][0]<min:
min=x[1][0]
ans=x[0]
POS=x[1][1]
elif x[1][0]==min:
if POS > x[1][1]:
min = x[ 1 ][ 0 ]
ans = x[ 0 ]
POS = x[ 1 ][ 1 ]
print(ans,dt[ans][0])