MCPcopy Create free account
hub / github.com/HuberTRoy/leetCode / missingNumber

Method missingNumber

Array/MissingNumber.py:38–53  ·  view source on GitHub ↗

:type nums: List[int] :rtype: int

(self, nums)

Source from the content-addressed store, hash-verified

36"""
37class Solution(object):
38 def missingNumber(self, nums):
39 """
40 :type nums: List[int]
41 :rtype: int
42 """
43 # x = list(set(range(max(nums)+1)) - set(nums))
44 # if x:
45 # return x.pop()
46 # else:
47 # return max(nums)+1
48 all_nums = sum(range(len(nums)+1))
49
50 for i in nums:
51 all_nums -= i
52
53 return all_nums

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected