4 ms·
Set insertion is O(1): https://stackoverflow.com/a/44080017 https://stackoverflow.com/a/44080017
by raldi 6y ago
Set insertion is O(1):
https://stackoverflow.com/a/44080017 https://stackoverflow.com/a/44080017
- margalabargala 6y agoSet insertion is O(n) in this case. An O(1) set insertion refers to constant time regardless of the size of the inserted element, but if you add one element to a set, then add a billion elements to the set, the latter will take about a billion times longer.
- deleted 6y ago[deleted]
- raldi 6y agoRight, inserting N items takes O(N), which is what I said.