LeetCode Easy Notebook - the plan
📑 On this page
The goal is not to dump answers. The goal is to build a notebook I can come back to before interviews and immediately remember the shape of the thinking.
For every Easy problem, I want the post to answer five things:
- What is the problem really asking?
- What is the first naive idea?
- What pattern does the problem belong to?
- What optimization makes it clean?
- What are the trade-offs and edge cases?
That means the LeetCode Notebook will stay as one series, and each solved Easy problem will be another entry inside it.
The writing template
Every solution should follow roughly this structure:
The problem in plain English
Before code, rewrite the problem. If I cannot explain it simply, I have not understood it yet.
The naive instinct
Start with the obvious solution, even when it is too slow. This is not wasted space. The naive version shows what the optimized version improves.
The reframe
This is the most important section. The reframe should name the pattern:
| Problem smell | Pattern to try |
|---|---|
| "Have I seen this before?" | Hash map / set |
| "Nearest previous/next thing" | Stack |
| "Sorted array" | Two pointers / binary search |
| "Subarray/window" | Sliding window |
| "Count ways" | Dynamic programming |
| "Tree path or depth" | DFS / BFS |
| "Linked list pointer movement" | Fast and slow pointers |
The accepted solution
Keep the code small and interview-readable. Prefer Python first because it makes the idea visible.
Other possibilities
This is where the notebook becomes useful:
- Could sorting help?
- Could a set replace a map?
- Could recursion be made iterative?
- Could this be solved in one pass?
- What changes if the input is huge?
- What changes if there are duplicates?
Complexity
End with time and space complexity, plus the reason behind each one.
First Easy batches
I will work through Easy problems by pattern, not random order.
| Batch | Focus | Examples |
|---|---|---|
| 1 | Hash maps and sets | Two Sum, Contains Duplicate, Valid Anagram |
| 2 | Stacks | Valid Parentheses, Baseball Game, Backspace String Compare |
| 3 | Two pointers | Palindrome checks, Merge Sorted Array, Remove Duplicates |
| 4 | Sliding window | Best Time to Buy and Sell Stock, Maximum Average Subarray |
| 5 | Binary search | Search Insert Position, Sqrt(x), First Bad Version |
| 6 | Linked lists | Reverse Linked List, Merge Two Sorted Lists, Linked List Cycle |
| 7 | Trees | Maximum Depth, Same Tree, Invert Binary Tree |
| 8 | Dynamic programming | Climbing Stairs, Min Cost Climbing Stairs |
The notebook can grow problem by problem, but the hidden curriculum is pattern recognition. That is the part that compounds.