File tree 1 file changed +56
-0
lines changed
1 file changed +56
-0
lines changed Original file line number Diff line number Diff line change
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
+ '''
1
36
# Single Number
37
+ '''
2
38
n=int(input())
3
39
a=[]
4
40
Count=2
15
51
break
16
52
17
53
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 ])
You can’t perform that action at this time.
0 commit comments