Skip to content

Commit ae27dd8

Browse files
find missing numbers in array
1 parent 82e5c94 commit ae27dd8

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
'''
2+
find missing numbers in array
3+
given: array having N-1 elements
4+
range: 1-N
5+
'''
6+
from collections import defaultdict
7+
N=int(input())
8+
a=list(map(int,input().split()))
9+
d=defaultdict(int)
10+
i=0
11+
while i<N-1:
12+
d[a[i]]=1
13+
i+=1
14+
i=1
15+
while i<=N:
16+
if d[i]==0:
17+
print(i)
18+
break
19+
i+=1

0 commit comments

Comments
 (0)