Security, experiments and writing · Python · Interview Prep · Summer 2026

ProblemSolving

Weekly algorithm practice, one pattern at a time: hash maps, tree recursion, and graph traversal. Each solution came with a comment explaining the key insight, not just what the code does. The demo below runs the actual Number of Islands DFS, animated cell by cell exactly as it recurses.

Arrays & Hash Maps Trees Graphs (BFS/DFS) Recursion

Click cells to draw land and water, then run it. This is the exact recursive dfs() from num_islands(), not a re-implementation, watch it flood-fill one island at a time and mark each one a different color as it's discovered.

Lit cells are land ('1'). Click any cell to toggle it before running.

Most interview problems reduce to a handful of recognizable patterns. These four came up constantly.

🗺️
Hash map lookup
Two Sum, Group Anagrams, Top K Frequent. Whenever a problem needs "have I seen this before" or "how many of these exist," a hash map turns an O(n²) scan into O(n).
🌳
Tree recursion
Solve for the root, trust the recursive calls to solve the subtrees. The one recurring mistake: validating a BST by checking only immediate children instead of passing down a valid range.
🕸️
Graph traversal
Number of Islands, Clone Graph, Course Schedule. Connected components, cycles, and shortest paths are all BFS/DFS with a visited set, the hard part is picking which one and what "visited" means.
🎯
Three-Color DFS
Cycle detection needs more than a simple visited/unvisited flag. Marking nodes unvisited, in-progress, and done distinguishes "revisiting a node in the current path" (a real cycle) from "revisiting a node we already fully explored" (not a cycle).

All four weeks of practice, in order.

What I learned

Register a node before its neighbors.

When cloning a graph, the copy has to be saved before going deeper. Otherwise a cycle never ends.

Two states are not enough to find a cycle.

Course Schedule needs three: not visited, in progress and done. Meeting a node that is in progress is a cycle, meeting one that is done is not.

A clear pattern beats a clever trick.

Number of Islands is only a search started once per island. Seeing that it is about connected parts is most of the solution.