Sharpen the knowledge of algorithms

There are the tips I apply when practicing leetcode algorithms, which is helpful for me to achieve more in less time.

1, Divide the problem-solving process into a few phases

The following problem-solving model always works for me.

1) Have the idea/solution on how to solve the problems. It means you know how to solve the problem. Normally I would write it down on a draft paper.

This one is the key process and lays the foundation for the following process.

2) Express your idea into the language you use

For me, it is Java. Normally one solution can divide into a couple steps. And just fulfill these steps.

3) Debug your solution

For the first run of the code, it is nearly 100% that it won’t pass all the test cases. Now it is time to use the test cases to make your code right.

4) Optional phase

There is always space for you to improve your code. For example, make your code reading-friendly and/or correctness-friendly, make the code run faster, make the code consume less memory, find other possible solutions.

2, count your time consuming for solving the problems

It makes sense. We won’t have tons of time to solve an algorithm problem in a technical interview.

3, Start from the easy questions, and move forward to those medium and difficulty ones

If you don’t take pleasure from torturing yourself, then start with the problems labeling easy. For me, the easy ones train my brain to have the solution for a specified type of questions, for example dynamic programming.

The other factor is that I am not quite an expert of Java. The easy one also gives me opportunity to examine my ability to express my idea in Java. If you are a really clever guy, you won’t have difficulty to solve a problem; your bottle-neck may be expressing your solution in a life-making programming language.

4, Practice on the same questions a couple times

You may learn more and deeply if your practice 10 questions, 10 times respectively, which will benefit you better than practicing 100 questions, once for each.

5, Set a task daily or weekly

Myself try to solve at least 2 problems everyday. Wow, it doesn’t sound greedy. Hmm, the report from leetcode shows that I have solved 3 questions in 5 days!!!!

One thought on “Sharpen the knowledge of algorithms

Leave a comment