← All topics

22 articles & lessons

Python

Articles and learning notes on python.

  1. Greedy & Backtracking — When to Use Each

    Two decision-making patterns that live either side of DP. Greedy: bet on the best local move and never look back — fast, occasionally wrong. Backtracking: explore every option and undo dead ends — slow, always right. Learn to prove greedy is safe, prune backtracking aggressively, and pick the right tool in 30 seconds.

    55 min read
  2. Dynamic Programming — Memoisation & Tabulation

    Break the problem down, cache the answer. Overlapping subproblems + optimal substructure = polynomial time from exponential recursion. Two dialects (top-down memo, bottom-up tabulation), one recipe (state → transition → base case → order), and the classic classics: Fibonacci, climbing stairs, coin change, LIS, edit distance.

    55 min read
  3. Binary Search — the Pattern Behind 100 Problems

    Sorted (or monotonic) + halving = O(log n). One template, three shapes: classic search, lower/upper bound, and binary-search-on-the-answer. The pattern behind git bisect, B-tree lookups, ship-in-D-days, and half the LeetCode medium set.

    55 min read
  4. Sorting — Merge, Quick, and When to Trust the Built-in

    The three sorts everyone should know (merge, quick, heap), why Python's sorted() beats them all, and the practice problems that ask you to implement them anyway.

    50 min read
  5. Graphs — Representation, BFS, DFS, Shortest Path

    The most general data structure — and the algorithms that turn ‘find the shortest / cheapest / connected’ problems into 20-line functions.

    50 min read
  6. Heaps & Priority Queues

    The data structure behind top-K, Dijkstra, event schedulers, and every job runner — how heapq works, when to use it, and the classic patterns that come up in serious production work.

    50 min read
  7. Trees & BSTs — Traversal (BFS/DFS)

    Trees are the recursive data structure that models everything hierarchical — DOM, filesystems, syntax, dependency graphs. Master traversal and balancing here, and every future algorithm gets easier.

    50 min read
  8. Recursion — Call Stack, Base Case, Worked Examples

    The mental model for solving problems by solving smaller versions of themselves — plus the tricks (memoisation, tail-form, iterative rewrites) that make it survive production.

    50 min read
  9. Stacks & Queues — LIFO/FIFO in Practice

    The two most important restricted data structures — and how they secretly power your function calls, browser history, printer queues, BFS, and every parser you've ever used.

    50 min read
  10. Linked Lists — Singly, Doubly, When They Win

    The data structure reviewers still love — plus the three real-world situations where a linked list actually beats an array.

    50 min read
  11. Hashmaps & Sets — Hash Functions, Collisions

    The single data structure that turns O(n) loops into O(1) lookups — how it actually works under the hood, why it can go pathologically slow, and the design review patterns you must own.

    50 min read
  12. Arrays & Strings — Indexing, Slicing, Two-Pointer

    The two data structures every algorithm question secretly starts from — and the two-pointer template that solves half of them in O(n).

    50 min read
  13. Type Hints, mypy, dataclasses & pydantic

    Modern Python that scales past 1000 lines: gradual typing with mypy, immutable value objects with dataclasses, and runtime-validated boundaries with pydantic v2.

    55 min read
  14. Testing with pytest — TDD Workflow

    Turn code from hope into evidence: real pytest patterns — parametrize, fixtures, mocks, coverage — plus the TDD loop that makes refactoring safe.

    55 min read
  15. Modules, Packages, Virtualenvs, pip & uv

    How Python code is organised, versioned, and shipped — from a single script to an installable package, with reproducible envs on every machine.

    55 min read
  16. Errors, Exceptions & Debugging with pdb

    The mindset shift that turns ‘print statement warrior’ into ‘engineer who kills bugs in minutes’. Try/except done right, custom exceptions, tracebacks decoded, pdb keystrokes memorised, and the modern replacements (icecream, ipdb, structlog).

    55 min read
  17. Inheritance, Composition & Polymorphism

    The single most-abused feature in OOP is inheritance. This session teaches the ‘composition first’ rule every senior codebase uses, plus the MRO, super() rules, ABCs, protocols, and how Python's duck typing makes half of Java's ceremony unnecessary.

    55 min read
  18. Classes & Objects — the OOP Mental Model

    Classes in Python are not what they are in Java. Everything is public, `self` is explicit, dunder methods are the interface. This session installs the mental model of what a class actually IS in Python — plus the three patterns you'll use daily.

    55 min read
  19. Data Structures — list, tuple, dict, set (when to use what)

    The one-page decision matrix that separates senior Python devs from the rest: given a data shape and a query pattern, know within 5 seconds which built-in structure to reach for — and its Big-O cost.

    55 min read
  20. Functions — arguments, scope, closures

    Functions are the atom of Python. This session covers the four kinds of arguments, the LEGB scope rule, closures, decorators as functions, and the classic tricks that trip up devs who thought they knew Python.

    55 min read
  21. Control Flow — if/else, loops, comprehensions

    The three shapes of Python control flow every dev needs to reach for on reflex — branches, loops, comprehensions — with the rules for when each one is right and when it silently becomes unreadable.

    50 min read
  22. Python Variables & Types — Mental Model of Memory

    Not ‘what is a variable’ — the actual model of what happens in memory when you write `x = [1, 2, 3]`. References, mutability, boxes, arrows. The mental picture every senior Python dev has that every junior doesn't.

    50 min read