How to Practice
Importance of the Exercise Section
Both beginner-focused and fast-track readers' guides include several exercise sections, which follow the explanation of the algorithm framework. The main purpose is to help you internalize the algorithm framework as your own knowledge, enabling you to independently apply it when encountering new problems.
Readers often ask, why do they understand the explanations but struggle with actual problem-solving? The reason is that you have not internalized the concepts.
These exercises are of moderate difficulty and can be directly applied using the framework. Through extensive and repetitive practice, you can easily internalize various algorithm-solving frameworks. Therefore, I emphasize that the exercise section is a crucial part of the learning process.
How to Use the Exercise Section
Here, I introduce a set of exercise methods that I have personally tested and found effective, for your reference.
Take Core Framework of Sliding Window Algorithm as an example. The corresponding exercise section is Exercise: Classic Problems of Sliding Window Algorithm.
First, you must thoroughly study the Core Framework of Sliding Window Algorithm and personally complete the example problems explained in the text.
The key step is to ensure that you can independently solve at least one new sliding window problem.
Don't just assume you've learned it; validate it to convince yourself.
The corresponding exercise section Exercise: Classic Problems of Sliding Window Algorithm contains suitable practice problems. Try solving them on your own without looking at the provided solutions. If you can't solve the first problem, move on to the next one, and so on.
The problems in the exercise section are carefully selected framework problems. It’s unlikely you won’t be able to solve any of them, as long as you think carefully.
As long as you can independently solve at least one problem, you can consider it a pass. For other problems, refer to my solutions to see where your thoughts got stuck and what can be optimized.
Review Methods for Exercise Sections
Reviewing is essential. I recommend revisiting the exercise section about three days after completing it.
Since you have already gone through it once, try not to look at my solutions during the review; instead, think through the solutions on your own. If you cannot solve a problem, check the answers, and then return to it after a few days until you can solve them independently.
Remember Not to Memorize Questions
Algorithms are not like rote learning; do not try to memorize problems, as it is ineffective. You should understand the principles of the algorithm, not just the specific problem-solving code.
For instance, do not just use <=
because you remember using it last time. This approach is unhelpful.
Forgetting the solution code is actually beneficial. It forces you to analyze and think critically as you write. You should be able to explain why <=
is used; that is what true review is. Otherwise, you are just memorizing without understanding, which is ineffective.