Skip to content

Commit 05db9d3

Browse files
python: add problem 136 and unittest
1 parent c7b2781 commit 05db9d3

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

Python/sln_101_200/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# -*- coding: utf-8 -*-
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# -*- coding: utf-8 -*-
2+
3+
class Solution_131_140:
4+
def singleNumber(self, nums):
5+
"""
6+
136
7+
:param nums:
8+
:return:
9+
"""
10+
val = {}
11+
for num in nums:
12+
if num not in val:
13+
val[num] = 1
14+
else:
15+
val.pop(num)
16+
return list(val.keys())[0]
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# -*- coding: utf-8 -*-
2+
from unittest import TestCase
3+
from sln_101_200.solution_131_140 import Solution_131_140
4+
5+
6+
class TestSolution_131_140(TestCase):
7+
def setUp(self):
8+
self.sln = Solution_131_140()
9+
10+
def test_singleNumber(self):
11+
ret = self.sln.singleNumber([2, 2, 1])
12+
self.assertEqual(ret, 1)

0 commit comments

Comments
 (0)