Skip to content

Commit 3404e54

Browse files
authored
Merge pull request #1323 from ivan1016017/july05
adding algo
2 parents 7d76693 + 1d9737a commit 3404e54

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed
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: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import unittest
2+
from src.my_project.interviews.top_150_questions_round_17\
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)

0 commit comments

Comments
 (0)