Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
wwwanlingxiao
LeetCodeAnimation
Commits
3559b302
Unverified
Commit
3559b302
authored
Aug 24, 2020
by
程序员吴师兄
Committed by
GitHub
Aug 24, 2020
Browse files
Merge pull request #113 from ztianming/patch-6
Update 0137-Single-Number-II.md
parents
93886784
5c8e809d
Changes
1
Hide whitespace changes
Inline
Side-by-side
0137-Single-Number-II/Article/0137-Single-Number-II.md
View file @
3559b302
...
...
@@ -46,5 +46,45 @@

### 代码实现
#### 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
```

\ No newline at end of file

Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment