Today we talk about how to brush, is expected to be divided into several articles to write, today is the first.
No more talking. Get straight to the business.
I recommend BFS
What I do is focus my time on just one type of problem. So on a certain kind of topic is very experienced, do the topic has the topic feeling, will not do a is a, the next encounter similar topic, even the original topic will not. In fact, many algorithms are closely related, and only after you have conquered enough topics can the knowledge of algorithms be fully understood.
I suggest that you should give priority to breadth and give up what you can’t do one by one, instead of giving priority to depth and “stumbling on a certain knowledge”. For example, if you can’t brush a tree DP, you should give it up and pick it up when you reach it.
It sounds simple, but which project should I start with, with so many titles?
Here is the table of contents for my 91-day quiz activities:
As you can see, our chapter arrangement is topic by topic, from simple to difficult. You can look at this model as well. If you really don’t know.
If you are too lazy to find and don’t mind me, you can refer to my Leetcode problem solving warehouse and brush down the questions, or take part in my 91-day learning algorithm.
BFS is about not understanding when necessary. Like, I’m getting dressed and I don’t know who you are? Let’s talk about the problem of extracting a lot of LIS from the longest ascending subsequence. Many people commented, “This is not efficient, it is better to be greedy! “.
I admit that. But my main purpose here is to give you a horizontal comparison, so that you can solve multiple problems in the same way.
If you want to see something efficient, it’s actually not hard. LIS can also achieve good efficiency with greed + dichotomy. The code is as follows:
The code text version is as follows:
class Solution:
def lengthOfLIS(self, A: List[int]) - >int:
d = []
for a in A:
i = bisect.bisect_left(d, a)
if i < len(d):
d[i] = a
elif not d or d[-1] < a:
d.append(a)
return len(d)
Copy the code
So WHAT I mean is that you should, at the right time, be unsophisticated and not pursue these things. Wait for everyone to learn a routine, let’s learn the next one. The so-called gentleman revenge, ten years not too late
And just as an aside, LIS is really useful, and you have to know, if you know how to square it, then you have to look at NlogNNlogNNlogN, and some of the HARD problems have to be nlognlognlogn to pass.
Take this question:
The following prompts follow:
3 <= nums.length <= 1000 1 <= nums[I] <= 109Copy the code
So if you look at this, you can probably estimate our time, n ^2log n ^2log n, n ^2log n, n ^2log n, n ^2log n, n ^2log n, n, n, n, n, n, n, n, n, n, n, n.
Once again, the number of brush questions is secondary, it is king to understand a class of questions, this is in fact and MY BFS brush problem big method echoes.
Routine is important
These above, in fact, are to help you identify routines, improve the efficiency of the brush. Knowing breadth first and knowing what questions to brush is not enough. Such as:
- What are the topics? How to deal with it?
- Do you have a template?
- How did I come up with this solution?
- , etc.
I’ve written a lot of articles about these issues. For example, some time ago, I wrote two special articles for you:
- Almost finished brushing all the tree buttons, I found these things
- After almost finishing all the links, I found these things
The response has been mostly positive.
Before, I also wrote a few solutions, is to buckle the same solution of the topic together, to help you solve the set, such as:
- I don’t know who you are with your clothes on? Let’s talk about the longest ascending subsequence
- I took your clothes off. – Longest Common subsequence.
I even wrote a series of motifs (which people didn’t like, so I didn’t update) :
- I am your Mother. – Issue one
If you read my paper carefully, it basically covers most of the topics under the project.
What do you want to see next? Welcome to my brush questions group to tell me (follow the public account “Li Kou Jia Jia” reply to Leetcode according to the prompts).
Master multiple programming languages
Brush questions and play games pay attention to speed, the world martial arts only fast not broken.
This fast, on the one hand is fast running speed, on the other hand is fast coding speed. You can see that a lot of people are skipping and switching languages during games. We need to acknowledge that efficiency varies from language to language, and that efficiency could be execution or coding. Which language to use depends on your needs.
In terms of coding speed, it must be faster in dynamic languages, and in terms of execution speed it must be faster in static languages. So my advice is to master at least one static language, one dynamic language, one static language.
My personal dynamic language Python and JS, static language Java and CPP, you can refer to.
One tip is to choose a language that is popular. So what languages are hot? It’s really easy. In the question solving area, the language ranking is high, as shown in the figure below:
Knowing the language not only helps you use it effectively, but also makes it easier to understand other people’s problems. In addition, there is another use, that is to go back to review. Take me as an example, I will not always go back to brush the questions I have done before, but a question is not fresh after doing, this time I will change the language to continue to brush, another taste.
Using mock interviews
This is a technique that I mentioned before. Liguo also has the function of mock interview, you can also have offline real whiteboard interview. In any case, it is recommended that you must have a sense of time and a standard AC.
Use the template
Many of the questions are template questions. You’ve summarized countless templates for me in the dichotomy section, and in fact there are many other sections, and you can go to my history article and read it.
But make sure you understand before you use templates. Don’t be direct without understanding that this is not good.
More tips, look forward to next time.
trailer
Finally, I’ll give you a piece of tidbits about the problem template above.
Next, licoojiajia’s brush plugin plans to introduce the brush template function.
- To provide you with a variety of brush template, can be directly copied to use.
- Each template has some questions, we can direct the topic to “write silently”.
- More functions, waiting for you to mention ~