From a8b7e8680562f46d1f7f7bc7639abfee5c702dd0 Mon Sep 17 00:00:00 2001 From: kushaliharish-wq Date: Thu, 3 Oct 2024 12:54:49 -0700 Subject: [PATCH] Done comp-1 --- missing_num.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 missing_num.py diff --git a/missing_num.py b/missing_num.py new file mode 100644 index 0000000..1d019ec --- /dev/null +++ b/missing_num.py @@ -0,0 +1,13 @@ +class Solution(object): + def missingNumber(self, nums): + """ + :type nums: List[int] + :rtype: int + """ + res = len(nums) + for i in range(len(nums)): + res += i - nums[i] + return res + + # time complexity is O(n) + # space complexity is O(1)