When I started preparing for placements and solving problems on LeetCode, I kept running into the same issue. If my data got too big and I needed to check if an item was already there, searching through a normal list took O(n) time, which was just too slow. I knew Python dictionaries were fast and gave O(1) lookups, but they need key-value pairs, which didn't always fit my problem. What I didn't know back then was that Python sets are just as fast. Once I understood how sets work internally using hashing, my solutions became much cleaner and faster. They help in: 1. Finding items instantly 2. Removing duplicates automatically 3. Writing more efficient and readable code I wrote a short blog post explaining how sets actually handle duplicates internally and why they are so helpful for solving problems. The link to my Medium blog: https://lnkd.in/gPphiy6E I would love to hear your thoughts. What is your favorite built-in Python feature? Special thanks to Innomatics Research Labs for supporting continuous learning and encouraging us to share knowledge openly. #Python #DataStructures #LearningInPublic #Coding #Programming #Hashing #LeetCode #SoftwareDevelopment #TechBlog
I like tuples in python, unlike lists they can be used as a key in a dictionary or set
Here’s the full blog: https://bit.ly/sets-python-performance Would love your feedback!