-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path260. Single Number III.py
More file actions
42 lines (36 loc) · 959 Bytes
/
260. Single Number III.py
File metadata and controls
42 lines (36 loc) · 959 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# 260. Single Number III
def single_number(nums):
data = {}
for i in nums:
if i not in data:
data[i]=1
else:
del data[i]
return list(data.keys())[:2]
def single_number(nums):
nums.sort()
data = []
for i in nums:
s = nums.count(i)
if s!=2:
data.append(i)
if len(data)==2:
return data
def single_number(nums):
n = len(nums)
result = [0, 0]
index = 0
for i in range(n):
found = False
for j in range(n):
if i != j and nums[i] == nums[j]:
found = True
break
if not found:
result[index] = nums[i]
index += 1
if index == 2:
break
return result
nums = list(map(int,input('enter the numbers: ').split(',')))
print(single_number(nums))