Hashing
Python Hashing Interview Questions
Hashing means using a dictionary or a set to look something up instantly, instead of searching the same list over and over. It is the standard answer when an interviewer asks you to make a working solution faster.
What hashing questions ask you to do
Across the questions here, these are the shapes that come up:
- Find two values that add up to a target
- Find the first repeated item, or the first unique one
- Group items by something you work out from them
- Count how often each value appears
- Check membership against a large collection inside a loop
Common mistakes with hashing
A list is not a set. Checking whether something is in a list searches the whole list every single time, so moving that check inside a loop leaves you with exactly the slow solution you started with, wearing nicer syntax.
Questions to practice
- Any duplicate transaction ids?Python
Visaeasy - First item bought twicePython
Instacarteasy - Customers who came backPython
Targetmedium - Longest run of consecutive daysPython
Pelotonmedium - Top pin categoriesPython
Pinterestmedium - Two homes that match a budgetPython
Zillowmedium - Which products repeat?Python
Wayfairmedium - Stretches that hit a targetPythonPremium
DoorDashhard
Questions last reviewed 19 October 2026.