# Demonstrate O(1) set membership vs O(n) list search

Canonical URL: <https://datadriven.io/problems/demonstrate-o1-set-membership-vs-on-list-search-create-7c818b5b>

Domain: Python · Difficulty: medium

## Problem

Demonstrate O(1) set membership vs O(n) list search. Create data_list = list(range(100000)) and data_set = set(range(100000)). Check if 99999 is in each. Print both results and print 'Set lookup is O(1)'.

## Related

- [All practice problems](https://datadriven.io/problems)
- [Mock interview mode](https://datadriven.io/interview/demonstrate-o1-set-membership-vs-on-list-search-create-7c818b5b)
- [Python Interview Questions](https://datadriven.io/python-interview-questions)
- [Data Engineering Interview Prep Guide](https://datadriven.io/data-engineer-interview-prep)
- [Daily Challenge](https://datadriven.io/daily)

---

Source: DataDriven (https://datadriven.io). 100% free data engineering interview prep. Live code execution against Postgres 16, Python 3.11, and Spark sandboxes. No paywall, no premium tier, no signup gate.