From 1c8077fda0687c66e7afc3875dbeafa64506ccf9 Mon Sep 17 00:00:00 2001 From: HyperWoo Date: Fri, 14 Oct 2022 01:14:37 +0530 Subject: [PATCH] Python Code for Smallest Positive in an Array --- Python/array/smallestPositiveNumber.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 Python/array/smallestPositiveNumber.py diff --git a/Python/array/smallestPositiveNumber.py b/Python/array/smallestPositiveNumber.py new file mode 100644 index 0000000..aff6947 --- /dev/null +++ b/Python/array/smallestPositiveNumber.py @@ -0,0 +1,17 @@ +def getMAX(a): + found = False + n = len(a) + for i in range(1, n + 2): + found = False + for j in range(n): + if a[j] == i: + found = True + break + if found == False: + return i + +#Driving Code + +a = [2, 3, 7, 6, 8, -1, -10, 15] + +print(getMAX(a)) \ No newline at end of file