Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 113db27

Browse files
python: add problem 137 and unittest
1 parent d29a3c4 commit 113db27

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Python/sln_101_200/solution_131_140.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# -*- coding: utf-8 -*-
2+
from typing import List
3+
24

35
class Solution_131_140:
46
def singleNumber(self, nums):
@@ -14,3 +16,11 @@ def singleNumber(self, nums):
1416
else:
1517
val.pop(num)
1618
return list(val.keys())[0]
19+
20+
def singleNumber_2(self, nums: List[int]) -> int:
21+
"""
22+
137
23+
:param nums:
24+
:return:
25+
"""
26+
return (sum(set(nums)) * 3 - sum(nums)) // 2

0 commit comments

Comments
 (0)