What is time complexity of a list to set conversion?
Solution 1:
Yes. Iterating over a list is O(n)
and adding each element to the hash set is O(1)
, so the total operation is O(n)
.
Yes. Iterating over a list is O(n)
and adding each element to the hash set is O(1)
, so the total operation is O(n)
.