Skip to content

Commit ea139c4

Browse files
.
1 parent b5e9f5d commit ea139c4

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

10X/Python/String/SingleNumber.py

+56
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,40 @@
1+
'''
2+
Single Number
3+
Given a list of N integers, every element appears twice except for one. Find that single one.
4+
5+
Input
6+
First number is N (the number of integers given) Followed by the N numbers
7+
8+
Output
9+
One line containing the output integer
10+
11+
Example
12+
Input: 3
13+
14+
2
15+
16+
2
17+
18+
1
19+
20+
Output: 1
21+
22+
Input: 5
23+
24+
2
25+
26+
2
27+
28+
1
29+
30+
1
31+
32+
3
33+
34+
Output: 3
35+
'''
136
# Single Number
37+
'''
238
n=int(input())
339
a=[]
440
Count=2
@@ -15,3 +51,23 @@
1551
break
1652
1753
print(p)
54+
only-50%
55+
'''
56+
n=int(input())
57+
a=[]
58+
Count=2
59+
60+
for j in range(n):
61+
a.append(int(input()))
62+
a=sorted(a)
63+
p=a[0]
64+
f=False
65+
for i in range(n-1):
66+
if a[i]!=a[i-1] and a[i]!=a[i+1]:
67+
p=a[i]
68+
f=True
69+
break
70+
if f:
71+
print(p)
72+
else:
73+
print(a[n-1])

0 commit comments

Comments
 (0)