Given an array of size N-1 such that it only contains distinct integers in the range of 1 to N. Find the missing element.
//first code
//for I in range(1,n+1):
// if I not in array:
// return I
// second code
// num_set = set(array)
// for i in range(1, n+1):
//if i not in num_set:
//return i
I don't understand when I run my code it give right answer but time taken is long and the below code pass all the test case why⁸