Skip to content

Commit 9072b09

Browse files
committed
Create 45. 只出现一次的数字.md
1 parent 5d88de6 commit 9072b09

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

45. 只出现一次的数字.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
***给定一个非空整数数组,除了某个元素只出现一次以外,其余每个元素均出现两次。找出那个只出现了一次的元素。***
2+
3+
```
4+
class Solution:
5+
def singleNumber(self, nums: List[int]) -> int:
6+
#异或运算
7+
ans = nums[0]
8+
for num in nums[1:]:
9+
ans = ans^num
10+
return ans
11+
```

0 commit comments

Comments
 (0)