The study process that I describe in these tips is based on model problems and model solutions. To write a good model solution, you can learn a process for writing it and the format that makes it most useful. The goal of LeetCode practice is to learn all the common problem types. Model solutions best support this goal when you write them in such a way that each concept is memorable. There are various techniques to make it easier to remember the concepts.

The last topic we need to consider for model solutions is the target audience. When an author writes an official LeetCode editorial or an unofficial solution in the discussion forums, they write it for a particular audience. They assume the reader is someone who wants to learn algorithmic coding interview problems, and has some basic programming experience. For an Easy problem, these may be the only prerequisites. For a Medium or Hard problem, the writer may assume knowledge of certain algorithms and data structures. Official LeetCode editorials for more advanced problems often link to a LeetCode Explore page and recommend that readers study before proceeding with the editorial.

When you write a model solution, the audience is much smaller. You can write it specifically for you. In fact, you can write it for you at a particular moment in your learning process. You can think of the model solution writing process as writing your own textbook. You are writing a textbook on LeetCode problems, a textbook that is customized for your unique background and skills and which you can update as these skills change and improve. The pages of your textbook are your model solutions, and the textbook represents everything you know about LeetCode problems.

Your textbook is organized around LeetCode problems because learning through problem-solving is the LeetCode philosophy. You choose the problems based on which concepts you need to learn and which problems are best suited to explore each concept. Taken as a whole, the problems in your textbook form a web of knowledge that covers the full set of LeetCode concepts that you have studied so far. The model solutions should reference each other so that as you learn one problem you also get better at related problems, even those that focus on different concepts.

Although problems are the organizing principle of your textbook, the fundamental concepts that you are learning are algorithms and data structures. The problems and the concepts mutually reinforce each other. As you learn your model solutions, you learn more about algorithms and data structures. And as you learn about algorithms and data structures, you get better at solving LeetCode problems. Although the goal is to show your problem-solving skills in an interview, the best way to remember how to solve these problems and apply the solutions to new problems is to understand every detail of how each problem works, both the theory behind the solution and the implementation details required to complete a working solution.

Like other types of textbooks, your LeetCode textbook will change over time. But unlike a textbook author, who might release a new edition every few years, you can update your textbook every day using that day’s practice session. Every repetition of a problem should point out a gap in your knowledge. (If it doesn’t, it means you’re done with a problem and you should remove it from your repetition queue). When you identify a gap, update your textbook with what you need to work on. And when you fill the gap through research and practice, update your textbook so you don’t forget your hard-won knowledge.

*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.*