From ab11386e4b863be645e825b8efa1d5a1a42d31a1 Mon Sep 17 00:00:00 2001 From: Siva Chellappa <95948259+siva-chellappa@users.noreply.github.com> Date: Wed, 29 Jan 2025 06:59:03 -0800 Subject: [PATCH] coding-1 coding-1 --- problem1.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 problem1.py diff --git a/problem1.py b/problem1.py new file mode 100644 index 00000000..352c9411 --- /dev/null +++ b/problem1.py @@ -0,0 +1,18 @@ +#time complexity - O(logn) +#space complexity - O(1) + +def find_missing_number(arr): + l=len(arr) + low=0 + high=l-1 + + if arr[0]!=1: + return 1 + + while low<=high: + mid=low+(high-low)//2 + if mid+1 != arr[mid]: + high=mid-1 + else: + low=mid+1 + return arr[high]+1 \ No newline at end of file