Skip to content

Commit

Permalink
Update 136.single-number.md
Browse files Browse the repository at this point in the history
  • Loading branch information
azl397985856 committed Oct 2, 2019
1 parent ba83b3a commit 0195458
Showing 1 changed file with 0 additions and 7 deletions.
7 changes: 0 additions & 7 deletions problems/136.single-number.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,6 @@ class Solution:
for num in nums:
single_number ^= num
return single_number
# 另一种思路:集合是无序不重复的元素集
# 利用这一特性将列表转化成不包含重复元素的集合
# 分别对集合和列表进行求和,集合元素之和 x2 减去列表元素之和即为只出现了一次的元素
class Solution:
def singleNumber(self, nums: List[int]) -> int:
return 2 * sum(set(nums)) - sum(nums)
```

## 延伸
Expand Down

0 comments on commit 0195458

Please sign in to comment.