test: adding more tests to missing number algorithm (#10394)

* test: adding more tests to missing number algorithm

* Update missing_number.py

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
This commit is contained in:
Abílio Azevedo 2023-10-29 18:43:32 -03:00 committed by GitHub
parent 13e66c18d2
commit 2531f8e221
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -11,6 +11,12 @@ def find_missing_number(nums: list[int]) -> int:
Example: Example:
>>> find_missing_number([0, 1, 3, 4]) >>> find_missing_number([0, 1, 3, 4])
2 2
>>> find_missing_number([4, 3, 1, 0])
2
>>> find_missing_number([-4, -3, -1, 0])
-2
>>> find_missing_number([-2, 2, 1, 3, 0])
-1
>>> find_missing_number([1, 3, 4, 5, 6]) >>> find_missing_number([1, 3, 4, 5, 6])
2 2
>>> find_missing_number([6, 5, 4, 2, 1]) >>> find_missing_number([6, 5, 4, 2, 1])
@ -26,3 +32,9 @@ def find_missing_number(nums: list[int]) -> int:
missing_number ^= i ^ nums[i - low] missing_number ^= i ^ nums[i - low]
return missing_number return missing_number
if __name__ == "__main__":
import doctest
doctest.testmod()