Why do programmers brush algorithms?
Because “roll”!
A joke, in fact, algorithm questions have become a way of screening people, big factory every round of interviews will have a few algorithm questions, and even some companies are all written algorithm questions. All the other questions are similar, then you can’t do the algorithm, you may be eliminated.
So why bother with algorithms? On the one hand is to help you learn and understand the algorithm, but on the other hand is also like back formula, back eight-essay, increase the probability of your interview encountered the original question. I brushed more than 1000 questions, and it’s no exaggeration to say that 80% of the algorithm questions in the interview were original questions.
Of course, everyone learning algorithm, brush the goal is different, first of all to clear your goal, because the target is different, brush algorithm platform and method is also different.
There are four common goals:
-
Learn basic programming syntax and ideas
-
I want to find a job in a big factory
-
Algorithm competition
-
Exercise your mind
Most of you should be aiming for the second one. Now in the programmer interview, algorithm questions are basic must be asked, so, in order to find a good job, more and more students realize the importance of brush algorithm, and even some students just began to learn programming, programming language is not familiar with, they want to brush algorithm in advance to prepare.
Why don’t we talk about how to brush for beginners?
Programming novice brush problem
For freshmen, most of them are just getting in touch with programming, so the goal of brushing the questions should be more inclined to the first one, that is, to help themselves learn programming.
LeetCode is indeed the most popular algorithm brush problem platform, but there is a big mistake is to brush LeetCode at the beginning, for programming white, basic programming syntax, functions, object-oriented are not good at it, brush what LeetCode? Learn about data structures and algorithms! ?
If you are not familiar with basic programming grammar, I suggest you do some basic exercises honestly. Most school teachers give homework, right?
For example, when I was a freshman, I was basically copying OJ (Online Judge) homework questions left by the teacher. Different from OJ of a series of famous universities such as tsinghua university and Peking University, we were copying simple questions, and each question was to solve a small problem, such as using C++ new class to build a car. The purpose is to help students learn C language, C++, Java and other basic syntax, familiar with the idea of object-oriented programming, so it is easier to get started.
Some students may feel that homework is difficult. In fact, most of the homework assigned by the school is very basic. If this is difficult, I think it is better to thoroughly understand the simple homework questions first than to try to brush the questions through the professional algorithm platform on the Internet.
Here I recommend the PTA program experimental assistant teaching platform, which provides many simple exercises suitable for beginners, such as basic programming topic set, Zhejiang University version of “C language Programming (3rd edition)” topic set, etc.
If you are already able to develop simple programs in a programming language, decide what your next goal is, in order to pass the interview algorithm? Or do you want to challenge yourself and enter a competition?
Below, I recommend some resources for different goals.
Job hunting brush
Nowadays, there are several algorithm questions in every round of interviews. Therefore, more and more young partners realize the importance of brushing questions.
In fact, there is no need to care too much about the platform, find a job to brush questions, choose LeetCode is enough, the most complete algorithm to brush questions website in China.
Many of my friends, like me, would doubt their intelligence when they first started using LeetCode.
I am a student majoring in computer science, and I have done some ACM topics and won some small competitions in my freshman year. However, when I first got to know Leetcode, I still felt as if I had stepped into a new world of ships, and I felt that I could not understand the above topics.
Later, when I communicated with others, I found that I was not alone. It was normal for me to brush Leetcode at the beginning because I was confused.
But as I got the hang of it, Leetcode wasn’t that scary after all. I started to brush the algorithm from the sophomore year, every day 2 hours, brush 2-3 questions, about a year later, the algorithm questions in the interview can be solved! It also helped me get some offers from big factories and finally joined the goose factory.
In total, I have swiped over 1000 algorithm questions, including over 600 on Leetcode alone (half simple and half medium). I have also swiped some interview questions on other platforms and books, such as Sword Finger Offer, Niuke, PAT, etc., which are all good.
I brush the Leetcode title
After brushing so many questions, I obviously feel that my thinking ability has been greatly improved, and I feel that Leetcode is not so difficult.
Think back to the first Leetcode led to doubt life, or you did not find the right way ~
So here is a simple way to share your LeetCode brush tips, I hope you don’t go wrong.
1. Brush the sequence of questions
Remember three points: brush from [learning plate LeetBook], brush from [easy], brush from [high pass rate]!
LeetBook is a special exercise on algorithms and data structures carefully organized by LeetCode (formerly called “Exploration”). Each topic corresponds to an important knowledge point, and a series of related topics lead you to get started. It is simpler and more practical than choosing topics piecemeal.
There are just a few things like interviews: trees, dynamic programming, depth/breadth first search, linked lists, arrays, sorting, stacks, queues, hashes, strings, etc. You will need to complete some simple questions in the specific exercise and understand the algorithms and data structures behind them. Then, practice more related problems, when you can use the same algorithm to solve a class of common problems, do multiple problems one solution, is really understood.
LeetBook special study
After finishing the column of Leetbook, enter the question bank and use LeetCode’s own question screening and sorting function to help us gradually brush the questions from simple to medium and then to difficult. Generally speaking, the first brush pass rate of higher questions, relatively easy.
2. Use problem solving
For each problem in LeetCode, there are many people who give solutions and explain how to solve the problem.
How do we use the problem?
First of all, the problem solving includes two parts: reading ideas and reading codes. We should not only understand the author’s ideas and logic of doing problems, but also learn excellent writing methods from others’ codes in detail. Even if you can solve this problem and beat 100%, I also suggest that you look at other people’s solutions, learn more about how they solve problems, and help yourself to open up your imagination and achieve multiple solutions to one problem.
In addition to LeetCode’s own solutions, there are plenty of other algorithmic solutions available on the web for every programming language!
For example, Google’s algorithm has gone viral:
Go language algorithm solution:
There is also Java Language Description of Data Structures:
More than one thousand problems of the solution ideas and methods.
And all the subject authors have also given the source code, readers can run directly.
How to read this note:
First read the questions by yourself and think about how to solve them. If you don’t have an idea in 15 minutes, read the author’s idea first, but don’t look at the code. Have ideas later with their own code to achieve again. If you can’t write at all, look at the code provided by the author and find out where you can’t write. Find out the problems and write them down. That’s what you need to fill in the gaps. If the implementation of their own, submitted after the error, their first debug. Before AC reaches 100%, think about how to optimize first. If each problem can be optimized to 100% by itself, then after a period of time there will be a lot of progress. So in general, there’s really no idea, look at the way to solve the problem; Really less than 100% optimization, look at the code.
The above resources have been sorted out, need a friend click here to get free screenshots;
In other words, there are too many problems on the Internet now! Just read one or two copies as you brush up, and don’t put too much pressure on yourself.
In addition to the problem solving, many students did not realize that writing problem solving is the real magic weapon, put their own problem solving ideas into writing, or tell others to listen to. This can not only deepen my impression of the topic, further deepen my understanding of the algorithm, help me review the problem solving process, so that it is easier to repeat in the interview; It can also help more students.
There are even some outstanding students who have published their own books before graduation by recording and sharing their solutions, earning hundreds of thousands or millions of dollars a year!
3. Keep improving
Each time you successfully solve a problem, the LeetCode system generates a solution report that tells you how many users your program has beaten in space and time.
It was good enough, but it wasn’t enough. During the interview, some interviewers will like to give you a variation of the problem, or ask you to solve the problem in a better way. So keep improving your code, finding more ideas and better solutions, until you beat 100% of your users, while still fully understanding the solution.
In our work, although we may not be directly dealing with algorithms, but learning algorithms to work really help a lot!
When solving algorithmic problems, we need to analyze the complexity of multiple algorithms and choose the optimal solution. In work, it is also the case that there are many ways to realize a requirement, and several different schemes are often designed to analyze their cost, performance and other differences and select the best one for implementation.
So take each algorithm problem seriously, treat it as an engineering problem, and trust that your mind will gradually open up and master the skills of writing high-performance programs.
4. Enter contests
I encourage you to take part in algorithmic contests, not ACM Regionals, but just to get a job.
In fact, websites like LeetCode and Niuke hold online algorithm competitions once a week to see who can solve problems the fastest and most in a limited time.
In the process of competition, the intense and exciting environment can keep our mind highly focused, can stimulate our thinking, so that we can think more in the limited time, and can also help us adapt to the pace of the interview. Join more and have a chance to win their official awards! Even though I never got a 555 once.
In addition, it is also good to participate in the Blue Bridge Cup competition. I also participated in two sessions, and the difficulty of the questions is similar to the algorithm questions required for job hunting. I can also find my own shortcomings and encourage myself to make progress.
5. Get a certificate
In recent years, the PAT Computer Programming proficiency test has been gradually warming up, divided into top, A, B three levels.
I have personally participated in grade A and GRADE B exams with moderate difficulty. Although this certificate is not valuable at present, you will have a learning goal and be more motivated to persevere in the process of preparing for the certificate. In my opinion, the process is greater than the result.
6. See article
Actually a lot of spare time, you can also use up, watching some of push, articles and so on, such as my sophomore summer internship sit high iron is watching cartoons to learn algorithm of gray, a 5-10 minutes, this time does not guarantee that you can learn to, but after watching the least can let you have a basic impression of algorithm. Time is like water in my head. Squeeze it and there is. If you want to get ahead of those who are more talented than you, you must use your time.
As for when to stop brushing questions? It depends on your purpose. Is it to find a job or to continue to exercise your mind and improve yourself?
Some colleagues around me still keep the habit of brushing algorithms, but after I found a job, my attitude towards algorithms is like an enemy. I don’t want to see them, but I can’t see them at all.
In any case, we must draw a long line and form a habit. It is best to fix a time every day and insist on doing several problems. For example, WHEN I was still lying in bed every morning, I took out my mobile phone to read a problem, and then closed my eyes and thought about the solution for a while before getting up and typing.
Do not rush to success, explosive brush questions! And unless you’re confident in the algorithm, I recommend not stopping until you get a job.
Finally, all things are difficult before they are easy. I hope you don’t doubt your ability, not to mention your IQ. Algorithm and programming language learning, find the right method, pay efforts, there will be progress!