题解 | #数组中只出现一次的数(其它数出现k次)#
数组中只出现一次的数(其它数出现k次)
http://www.nowcoder.com/practice/5d3d74c3bf7f4e368e03096bb8857871
python只能调用ctypes来做吹了位运算的结果了
class Solution:
def foundOnceNumber(self , arr , k ):
# write code here
res = 0
for i in range(32):
cur = 0
for t in arr:
cur += (t >> i) & 1
res ^= (cur % k) << i
import ctypes
return ctypes.c_int(res).value
阿里巴巴公司氛围 653人发布