0

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

  1. in the above code will the time complexity be O(n)?
  2. Is it that for time complexity to be O(n) there has to be a for loop?
juanpa.arrivillaga
  • 88,713
  • 10
  • 131
  • 172
Soham
  • 11
  • 1
  • 1

0 Answers0