题目描述

一个整型数组里除了两个数字之外,其他的数字都出现了两次。请写程序找出这两个只出现一次的数字。
 
# -*- coding:utf-8 -*-
class Solution:
    # 返回[a,b] 其中ab是出现一次的两个数字
    def FindNumsAppearOnce(self, array):
        hash = {}
        res = []
        for i in array:
            if str(i) in hash:
                hash[str(i)]+=1
            else:
                hash[str(i)] = 1
        for k in hash.keys():
            if hash[k] ==1:
                res.append(k)
        return res

print(Solution().FindNumsAppearOnce([2,4,3,6,3,2,5,5]))

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-07
  • 2021-11-14
  • 2021-08-29
  • 2021-07-18
猜你喜欢
  • 2022-12-23
  • 2021-06-07
  • 2021-11-06
  • 2021-05-30
  • 2022-01-15
  • 2022-01-19
  • 2021-10-24
相关资源
相似解决方案