feat: find_missing

This commit is contained in:
2025-11-23 23:15:49 +01:00
parent a26970f873
commit feb122711a
2 changed files with 20 additions and 1 deletions

View File

@@ -9,3 +9,14 @@ def maximum_subarray_sum(input_array: list[int]):
max_sum = temp_sum max_sum = temp_sum
subarray = temp_subarray subarray = temp_subarray
return [max_sum, subarray] return [max_sum, subarray]
def get_array_range(min, max):
arr = []
for n in range(min, max + 1):
arr.append(n)
return arr
def find_missing(input_aray: list[int]):
return sum(get_array_range(1, len(input_aray) + 1)) - sum(input_aray)
def trap_rain_water(input_aray: list[int]):

View File

@@ -16,4 +16,12 @@ def test_subarray_sum():
expected = [25, [5,4,1,7,8]] expected = [25, [5,4,1,7,8]]
assert result == expected assert result == expected
def test_find_missing():
input = [8,2,4,5,3,7,1]
result = find_missing(input)
expected = 6
assert result == expected
input = [1,2,3,5]
result = find_missing(input)
expected = 4
assert result == expected