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)
.
More Related Contents:
- Get difference between two lists
- Python Sets vs Lists
- Python -Intersection of multiple lists?
- In Python, when to use a Dictionary, List or Set?
- What makes sets faster than lists?
- Why can a Python dict have multiple keys with the same hash?
- Add list to set
- How to construct a set out of list items in python?
- How to compare a list of lists/sets in python?
- Why aren’t Python sets hashable?
- How to make a set of lists
- What is the difference between sets and lists in Python?
- Get unique values in List of Lists
- Which is faster and why? Set or List?
- Fastest way to search a list in python
- Sliding window maximum in O(n) time
- Get difference between two lists with Unique Entries
- set of list of lists in python
- How to convert a set to a list in python?
- What is the cost/ complexity of insert in list at some location?
- Python frozenset hashing algorithm / implementation
- What is the time complexity of Python List Reverse?
- Find non-common elements in lists
- Why and how are Python functions hashable?
- Python and SQLite: insert into table
- How to combine elements from two lists into a third?
- Creating a list in Python with multiple copies of a given object in a single line
- How can I turn a flat list into a 2D array in python?
- Sum list of list elements in python like sql group by [duplicate]
- Python : how to append new elements in a list of list?