code:
x=[10,20,30,40,50]
y=20
if(y in x):
print(x.index(y))
else:
print(-1)
Please help me with the below 2 Questions
- in the above code will the time complexity be O(n)?
- Is it that for time complexity to be O(n) there has to be a for loop?