1. 程式人生 > >劍指offer:陣列中只出現一次的數字(python)

劍指offer:陣列中只出現一次的數字(python)

題目描述

一個整型數組裡除了兩個數字之外,其他的數字都出現了兩次。請寫程式找出這兩個只出現一次的數字。
# -*- coding:utf-8 -*-
class Solution:
    # 返回[a,b] 其中ab是出現一次的兩個數字
    def FindNumsAppearOnce(self, array):
        # write code here
        temp = []
        for a in array:
            if a in temp:
                temp.remove(a)
            else:
                temp.append(a)
        return temp