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 2731ebc commit eab82f5Copy full SHA for eab82f5
Arrays/P03_GetMissingNumber.py
@@ -0,0 +1,23 @@
1
+# Author: OMKAR PATHAk
2
+
3
+from Arrays import Array
4
5
+def findMissing(myArray, n):
6
+ n = n - 1
7
+ totalSum = (n * (n + 1)) // 2
8
+ for i in range(0, n):
9
+ totalSum -= myArray[i]
10
11
+ return totalSum
12
13
+if __name__ == '__main__':
14
+ myArray = Array(10)
15
+ for i in range(len(myArray)):
16
+ myArray.insert(i, i)
17
+ myArray.delete(4, 4)
18
+ print('Original Array:',myArray)
19
+ print('Missing Element:', findMissing(myArray, len(myArray)))
20
21
+ # OUTPUT:
22
+ # Original Array: 0 1 2 3 5 6 7 8 9 0
23
+ # Missing Element: 4
0 commit comments