Back to course home
0% completed
Vote For New Content
One way to look at this is:Place all numbers in their correct position except n....
Gideon
Apr 13, 2022
One way to look at this is:
Place all numbers in their correct position except n.
At the end, n will be at the missing index.
if n is the missing number, all other numbers will be in the correct position, hence return n at the end.
7
0
Comments
Comments
Miguel 2 years ago
#I did the same. Here is the example: def findMissingNumber(self, nums): i, n = 0, len(nums) missing = n for i in range(n): while nums[i] != i: if nums[i] == n: missing = i break else: ...
On this page