Hash Table from Scratch in Python: Chaining, Resizing and Interview Questions
Build a hash table in Python from scratch with chaining and open addressing, then see collisions, resizing, bad hashes and the tombstone bug that catches most candidates.
Clear, step-by-step guides to data structures, algorithms and LeetCode problems, with Python solutions and complexity analysis.
def two_sum(nums, target):
seen = {}
for i, n in enumerate(nums):
need = target - n
if need in seen:
return [seen[need], i]
seen[n] = i
# One pass, O(n) time, O(n) space
Every guide belongs to one topic, so you can study in order.
Build a hash table in Python from scratch with chaining and open addressing, then see collisions, resizing, bad hashes and the tombstone bug that catches most candidates.
Practise TCS NQT and Infosys style coding rounds in Python: judge-proof input handling, Python numeric traps, seven tested practice problems…
Two core DP patterns in Python: 0/1 knapsack with the loop-direction trap, and Longest Increasing Subsequence with the bisect trick,…
Six bit tricks interviews reuse, with tested Python: power of two, lowest set bit, XOR cancellation, subset masks, and why…
Build a trie in Python with prefix search, autocomplete and wildcard matching, then see when a sorted list with bisect…
Arrays, strings and hash maps. Learn to spot when a lookup table removes a nested loop. Start here.
Two pointers, sliding window and binary search cover a huge share of easy and medium problems. Binary search.
Recursion, DFS, BFS and backtracking. Practise drawing the call stack before you code. Trees and graphs.
Move from recursion to memoization to tabulation, then do timed mock interviews. Dynamic programming.
Interview preparation is mostly about understanding, not memorising answers. Each article explains the idea in plain language first, then shows the code.
I am a second-year BTech student and the person behind LeetPrep. I choose every topic, review and edit each guide before it goes live, and read every message that comes through the contact page. Code examples are tested before they are published.
More about the author →Tell us which problem or concept gave you trouble and we will consider writing a guide on it.
Contact us