Ask any experienced LeetCoder what you should do to improve, and they’ll give you the same answer: practice. These tips also focus on practice, and for good reason. If you want to learn to solve LeetCode problems, there’s no substitute for practice. And it’s challenging to practice consistently, so regular reminders can be helpful. But you can’t just practice.
In Most Books Won’t Change Your Life (But You Should Read Them Anyway), Scott Young considers the value of “advice books,” defined broadly as any book that might convince you to change something in your life. As anyone who has tried to implement advice can attest, it’s a lot easier to read advice than it is to make a change. So the question is: should we only read an advice book if we have time to try out what it recommends?
Translating this question to the world of LeetCode practice: Should you only read a book or article if it applies directly to your current practice topic? For example, if you’re learning binary search, should you only read the binary search section in an algorithms textbook, or maybe something about loops and arrays?
The idea of mapping your reading list to your practice schedule seems reasonable. Technical material is hard to read and understand. Pairing it with a hands-on problem-solving is a standard way to make learning more effective.
But Scott, using the economics concepts of marginal costs and marginal benefits, argues that it’s worth reading more than just what you can directly use. In this calculation, marginal costs are the costs of buying and reading books. For example, a typical nonfiction book (not a textbook) might cost $20 and require 20 hours to read. If the marginal benefit you get from reading it is more than $20 plus the value of 20 hours of your time, you come out ahead.
To help calculate the marginal benefit of reading, here are some ways that reading can help with coding practice, beyond just showing you how to solve a problem:
Avoid bad choices: A book can warn against bad architecture, design, or practice choices, so you know to avoid them.
Build your idea list: When you’re ready to implement a new idea, like a problem-solving strategy or an algorithm, you can only pick from the ones you know about. When you read about an idea, you can add it to your list. If you regularly add to your list, and bubble better ideas to the top, you’ll always have good ideas to choose from.
Create patterns of thinking: Some ideas are more about a general approach than a specific procedure. For example, the idea of keeping a practice journal can help you become more intentional about your learning. Once you know about that idea, you can implement it as you work on other things. It’s not the type of idea that you have to carve out time to practice on its own.
Find coding buddies: If you work or study with experienced people, some of it will rub off on you. Reading books lets you learn from a wide range of experts, even if you don’t work with them directly.
Win the coding lottery: Beyond the reliable benefits of reading, there is the element of luck. It’s always possible that you could read something in a book that helps you pass an interview or solve a difficult problem at work. The potential benefit of such an event could more than make up for what you invest in your reading habit.
This year, I’m publishing a series of tips for effective LeetCode practice. To read the tips in order, start with A Project for 2023.