Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- my_list = [-106, 222,222,106,74,66,195,627,731,750,586,874,599,878,759,807]
- print(len(my_list)) # list er lenght jodi hoy 5 -> money 5, 10
- #5 -> money 5
- #10 -> money 10
- #100000000 -> money 100000000
- #3 -> money 3
- #X -> money X
- #N -> money N <======== O(N)
- #money/time/space = resource ^
- target = -106
- found = False #flag
- money = 0
- for item in my_list:
- money = money + 1
- if item == target:
- found = True
- break
- print('money:',money)
- if found == True:
- print('Found the target: ',target)
- else:
- print('Did not find the target')
Advertisement
Add Comment
Please, Sign In to add comment