Python Perm Missing Element
def perm_missing_element(a: list[int]) -> int:
a = sorted(a)
for k, v in enumerate(a):
if v != k + 1:
return k + 1
return len(a) + 1
This uses the expected sum of 1..N+1 and subtracts the actual sum to find the missing value.