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 confirmed to be effective, for your reference.
Let's take The Core Framework of the Sliding Window Algorithm as an example. The corresponding exercise section is Strengthening Exercises: Classic Problems of the Sliding Window Algorithm.
First, you should thoroughly study The Core Framework of the Sliding Window Algorithm and complete the example problems explained in the text by yourself.
Here's the crucial part: You need to ensure that you can independently solve at least one entirely new sliding window problem.
It's not enough to just feel like you've learned it. If you don't test yourself, do you truly believe it?
The exercise section Strengthening Exercises: Classic Problems of the Sliding Window Algorithm provides suitable practice problems. Initially, avoid looking at the solutions provided by me. Try to think and solve them on your own. If you really cannot solve the first problem, don't get stuck on it; you can try the next one, and so on.
The problems in the exercise section are carefully selected framework questions. It's improbable that 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 success. For the other problems, you can refer to my solutions to see where your thought process got stuck and what can be improved.
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.