Interview-grade, fully-explained solutions to the problems in
../guides/Python_Leetcode.md, organized by pattern. Built as
study material for an AI/ML Engineer interview track.
Every solution is PEP 8 / pylint-clean, type-hinted, paste-ready into the
LeetCode editor, and self-testing (python file.py runs its examples). The
module docstring teaches the pattern and the why, not just the code. See
STYLE.md for the standard and TEMPLATE.py for the
canonical shape.
- Pick a category folder. Read its
README.md— it frames the pattern and lists every problem with its key idea and complexity. - Attempt the problem cold (20-min timer). Then read the solution file.
- Run it:
python 01-arrays-hashing/0001_two_sum.py→All tests passed. - Re-do anything you couldn't solve in time. Patterns over volume.
| # | Folder | Pattern focus | ML relevance |
|---|---|---|---|
| 01 | 01-arrays-hashing |
Hash maps, sets, frequency counts | Dedup, vocab building, embedding lookups |
| 02 | 02-two-pointers |
Opposite / slow-fast pointers | In-place array ops |
| 03 | 03-sliding-window |
Fixed & variable windows | Sequence/window stats, pooling |
| 04 | 04-stack |
Stack matching, monotonic stack | Expression parsing |
| 05 | 05-linked-list |
Pointer manipulation, Floyd's cycle | Streaming structures |
| 06 | 06-trees |
DFS/BFS, recursion, BST property | Decision trees, hierarchies |
| 07 | 07-binary-search |
Classic + search-on-answer | Threshold tuning |
| 08 | 08-math-bit-manipulation |
Bit tricks, integer math | Masking, hashing |
| 09 | 09-dynamic-programming |
1-D DP, memoization | Sequence models, DTW intuition |
| 10 | 10-graphs |
Grid DFS/BFS | GNNs, knowledge graphs |
Phase 1 — Easy (this answersheet): all 60 Easy problems solved to gold standard.
| Category | Easy | Medium | Hard |
|---|---|---|---|
| Arrays & Hashing | ✅ 10/10 | scaffolded | scaffolded |
| Two Pointers | ✅ 7/7 | scaffolded | — |
| Sliding Window | ✅ 3/3 | scaffolded | scaffolded |
| Stack | ✅ 4/4 | scaffolded | — |
| Linked List | ✅ 6/6 | scaffolded | — |
| Trees | ✅ 10/10 | scaffolded | scaffolded |
| Binary Search | ✅ 4/4 | scaffolded | scaffolded |
| Math & Bit | ✅ 9/9 | scaffolded | — |
| Dynamic Programming | ✅ 5/5 | scaffolded | scaffolded |
| Graphs | ✅ 2/2 | scaffolded | scaffolded |
Medium and Hard tiers are listed in each category README as the next phase.
- Naming: folders
NN-kebab-case, filesNNNN_snake_case_title.py. - Self-contained: helper types (
TreeNode,ListNode) are defined in-file, exactly as LeetCode provides them. Solution bodies import only the standard library. - Idioms ML interviewers notice:
collections.Counter,defaultdict,deque,heapq,bisectused fluently and deliberately.