What is the time complexity of the sum() function?
It depends on your data structure. For a flat list, you cannot do better than O(n) because you have to look at each item in the list to add them up.
When in doubt, try it out: import profile
is your friend.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With