Skip to content

Commit 1244e8d

Browse files
committed
adding single number
1 parent e4faefe commit 1244e8d

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from typing import List, Union, Collection, Mapping, Optional
2+
from abc import ABC, abstractmethod
3+
4+
class Solution:
5+
def singleNumber(self, nums: List[int]) -> int:
6+
7+
answer = 0
8+
9+
for num in nums:
10+
answer ^= num
11+
12+
return answer
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import unittest
2+
from src.my_project.interviews.top_150_questions_round_12\
3+
.single_number import Solution
4+
5+
class SingleNumberTestCase(unittest.TestCase):
6+
7+
def test_single_number(self):
8+
solution = Solution()
9+
output = solution.singleNumber(nums=[2,2,1])
10+
target = 1
11+
self.assertEqual(output, target)
12+
13+

0 commit comments

Comments
 (0)