Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2d4c2e6

Browse files
committed
add 136
1 parent 7e0907d commit 2d4c2e6

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

‎LeetCodeSolutions/136.py‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#==================================================
2+
#==> Title: 136. 只出现一次的数字
3+
#==> Author: Zhang zhen
4+
#==> Email: hustmatnoble.gmail.com
5+
#==> GitHub: https://github.com/MatNoble
6+
#==> Date: 2/22/2021
7+
#==================================================
8+
9+
from typing import List
10+
class Solution:
11+
def singleNumber(self, nums: List[int]) -> int:
12+
# from collections import Counter
13+
# return sorted(Counter(nums).items(),key=lambda x:x[1])[0][0]
14+
for num in nums[1:]:
15+
nums[0] ^= num
16+
return nums[0]
17+
18+
mat = Solution()
19+
nums = [2,3,2,1,1]
20+
mat.singleNumber(nums)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /