## 题目

Given a non-empty array of integers, every element appears three times except for one, which appears exactly once. Find that single one.

Note:

Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?

Example 1:

Example 2:

## 思路

• 通解: 对于任意参数为k,p问题，输入数组每个元素都出现了k次，只有一个只出现了p次，求那个单独的只出现p次的数，都可以用求和的方式解决。例如原始的Single Number问题，是k=2, p=1，则可以用两倍所有非重复元素的和，减去原数组即可，即2 * sum(set(nums)) - sum(nums)