Python-Algos: Find the Missing Element

Consider an array of non-negative integers. A second array is formed by shuffling the elements of the first array and deleting a random element. Given the two arrays, find which element is missing in the second array.

def findt_missing(arr1,arr2):
arr1.sort()
arr2.sort()

for num1, num2 in zip(arr1,arr2):
if num1 != num2:
return num1
return arry1[-1]

The zip() function returns a zip object, which is an iterator of tuples where the first item in each passed iterator is paired together, and then the second item in each passed iterator are paired together etc.

If the passed iterators have different lengths, the iterator with the least items decides the length of the new iterator.

a = ("John", "Charles", "Mike")
b = ("Jenny", "Christy", "Monica")
x = zip(a, b)
print(tuple(x))
Reslult:
(('John', 'Jenny'), ('Charles', 'Christy'), ('Mike', 'Monica'))

The bigO notation for the solution of our problem is nLog(n).