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.
Roles this comes up in
Companies these come from
Other topics
- Filtering7
- Logical operators4
- Calculations11
- Conditional logic12
- NULL handling9
- Dates16
- Joins15
- Aggregations14
- Subqueries5
- Window functions32
- Reshaping15
- Arrays6
- Strings11
- Two pointers4
- Sliding window1
- Binary search4
- Sorting1
- Math3
- Lists5
- Tuples3
- Dictionaries3
- Ranking16
- Running totals10
- Deduplication2
- Chunking1
- Similarity1
- Token budget2
- Parsing4
- Backoff3
- Agent loop1
- Cost1