未验证 提交 3559b302 编写于 作者: 程序员吴师兄 提交者: GitHub

Merge pull request #113 from ztianming/patch-6

Update 0137-Single-Number-II.md
......@@ -46,5 +46,45 @@
![](../Animation/137.gif)
### 代码实现
#### C++
```c++
class Solution {
public:
int singleNumber(vector<int>& nums) {
int one=0, two=0;
for(int n:nums)
{
one = (one ^ n) & (~two);
two = (two ^ n) & (~one);
}
return one;
}
};
```
#### Java
```java
class Solution {
public int singleNumber(int[] nums) {
int one=0, two=0;
for(int n:nums)
{
one = (one ^ n) & (~two);
two = (two ^ n) & (~one);
}
return one;
}
}
```
#### Python
```python
class Solution(object):
def singleNumber(self, nums):
one = two = 0
for n in nums:
one = (one ^ n) & (~two)
two = (two ^ n) & (~one)
return one
```
![](../../Pictures/qrcode.jpg)
\ No newline at end of file
![](../../Pictures/qrcode.jpg)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册