Guest User

Untitled

a guest
Oct 21st, 2019
77
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import timeit
  2.  
  3. setup = '''
  4. arr = [1,5,7,8]
  5. target, table = 9, {}
  6. '''
  7. my_code = '''
  8. def two_sums(arr, target):
  9. for i, _ in enumerate(arr):
  10. for j in range(i+1, len(arr)):
  11. if ((arr[i] + arr[j]) == target):
  12. return [i, j]
  13. break
  14. return
  15. '''
  16. print("time in seconds: ",timeit.timeit(setup = setup, stmt = my_code, number=10000)) #0.01
RAW Paste Data