The Leet-Code repo is an algorithm practice notebook. The Python solutions are organized by problem number, and they mix brute-force versions, optimized attempts, and exploratory notes.
Read in order, the code shows the path from a direct approach to a better pattern.
Patterns in the Repo
Many problems fall into common categories: arrays, strings, hash maps, sorting, two pointers, recursion, dynamic programming, and basic math.
Examples include Two Sum, Longest Substring Without Repeating Characters, Climbing Stairs, Longest Consecutive Sequence, Two Sum II, Contains-like matching problems, and subarray counting.
Learning Value
Some solutions are intentionally simple. Brute force is often the first version that proves the idea. Later the same problem can be revisited with a hash map, a sliding window, a dynamic programming table, or a sorted scan.
The progression matters: interview-style problems are mostly pattern recognition under constraints.
Knowledge Points
- A hash map often turns a repeated-lookup problem from quadratic time into linear time.
- A sliding window helps when a substring or subarray has to satisfy a constraint that moves as you scan.
- Two pointers work when the input is sorted, or when you can scan it from both ends.
- Dynamic programming stores the results of overlapping subproblems instead of recomputing them.
- Sorting can simplify a problem, at the cost of O(n log n) time.
- Recursion is expressive, but repeated states usually need memoization.
- Keeping notes next to the code makes mistakes and improvements easier to revisit.
Takeaway
The repo is a learning record more than a product. Its next step is complexity notes and a short reflection for every solved problem.