Design and implement an algorithm for the following problem: Given an unsorted list of \(n-1\) different numbers from the interval \(1..n\), find the missing number.

Assignment

Write a Python function findMissingNumber(x: list) that returns the missing number in a given list.

Examples

>>> findMissingNumber([1, 3, 4, 5])
2
>>> findMissingNumber([1, 2, 4, 5])
3
>>> findMissingNumber([1, 2, 3, 4, 6])
5
>>> findMissingNumber([1, 3])
2