We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 82e5c94 commit ae27dd8Copy full SHA for ae27dd8
DP/Hashing/find missing numbers in array.py
@@ -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
0 commit comments