I am trying to submit a problem, whose question is mentioned below:
You are given all numbers between 1,2,…,n except one. Your task is to find the missing number.
Input
The first input line contains an integer n.
The second line contains n−1 numbers. Each number is distinct and between 1 and n (inclusive).
Output
Print the missing number.
Constraints
2≤n≤2⋅105
Example
Input:
5
2 3 1 5
Output:
4
My Solution( In Python):
l = []
n = int(input())
l = [int(item) for item in input().split()]
for i in range(1,n):
if i in l:
None
else:
print(i)
I am getting a TLE error in some of the test cases, due to which I’m unable to submit it. Though, it has passed all the other test cases successfully.
Any help or guidance would be appreciated