题目描述:
一个整型数组里除了两个数字之外,其他的数字都出现了两次。请写程序找出这两个只出现一次的数字。
实现:
# -*- coding:utf-8 -*-
class Solution:
# 返回[a,b] 其中ab是出现一次的两个数字
def FindNumsAppearOnce(self, array):
# write code here
hash_dic={}
for item in array:
hash_dic[item]=hash_dic.get(item,0) + 1
res=[]
for key,val in hash_dic.items():
if val == 1:
res.append(key)
return res
来源:CSDN
作者:fly_Xiaoma
链接:https://blog.csdn.net/weixin_38664232/article/details/103514547