The spring recruitment season is approaching, and everyone has begun to prepare for interviews to win their favorite offers.
This time, lucifer will share with you some interview skills from the perspective of the interviewer, so that you can avoid detours during the interview. This sharing focuses on algorithm interview .
I have been in charge of the company's interviews for more than 5 years, basically the first interview and the second interview. Therefore, the technical interview is relatively deep, and more is to understand whether the technical ability of the candidate is up to standard. In the past few years, I have also interviewed many candidates. Some of these people are not technically capable, but it is a pity that some of them are technically capable, but they failed to pass my interview. Why?
What is interviewed for?
First, there are usually the following criteria for judging whether a candidate can pass the interview:
- Can the skills work
- How is the communication ability
- How is the enthusiasm for work
。。。
Then, when I interviewed, it was definitely based on the above, but the emphasis was different.
Algorithm questions and programming questions can actually test the above information very well, not just whether the ability of is competent for . The premise is that the interviewer can't be too rigid, such as throwing an original online question directly, and some even take it out for the test even if they are not very good at it. This is definitely not acceptable.
Some students reported that the algorithm problem was made, but they failed the interview. what about this?
In addition to taking it for granted that it does a good job, in fact the corner case is not considered or is not the optimal solution. It is still possible to be hung up, why?
In fact, you have done a good job in the subject, and it can only prove that the ability of can be competent for . This does not mean that other requirements are also met, such as the communication skills mentioned above, work enthusiasm and so on.
So how do you better present yourself and make a better impression on the interviewer to pass the interview? In addition to improving one's own technical prowess, the method is also very important. Here I summarize a few tips for you.
Algorithm Interview Basic Steps
- I found an "Interview Cheat Sheet" online, this PDF lists the template steps for an interview, with detailed instructions on how to complete the interview step by step.
The beginning of this pdf mentions three criteria for good code:
- readability
- time complexity
- space complexity
This is so well written.
Next, it lists the steps of 15 algorithm interviews. For example, step 1: After the interviewer has finished asking questions, you need to get down to the key points first (and then write comments and code below). After reading it, my feeling is that as long as the interview is done according to this, the success rate will increase.
- Ask several times to make sure you understand the question correctly.
Such as input and output, corner case and so on. Imagine a colleague who gets a requirement indiscriminately and does it indiscriminately, only to find that it is not right. How embarrassing? Would you like to work with such a colleague?
For example, you can ask:
- Do you need to consider negative numbers?
- Does the order of results matter?
- Can extra space be used?
- 。。。
- Think first, then write code.
Although there is no problem with understanding the question, it may be that the idea is not right at all, or the interviewer does not want this solution.
Imagine that you are the interviewer, writing code for half a day. The idea is not right at all or it is not the solution you want, are you a little disappointed?
So try to talk about ideas first, the interviewer thinks there is no problem and then write, Don't waste each other's time .
For example you can say:
- The idea of simple violence is: xxxx. In doing so, the time complexity is xxxx.
- The bottleneck of the simple brute force algorithm is xxx, we can use the xxxx algorithm to optimize, so that the complexity can be optimized to xxxx.
- When explaining ideas to the interviewer in the previous step, substitute a few examples.
Both corner case and normal case are given at least one to illustrate. This will not only make the interviewer feel that you have strong communication skills, but also help you to further understand the topic and clarify your ideas.
There are times when everyone is nervous during the interview, and the tension will gradually decrease after explaining with examples. It’s like when I share technology, I tend to be nervous in the first few minutes, and then I don’t feel nervous afterward.
For example you can say:
- When the input is [1,2,3,4], our first xxxx, so that is xxxx, then calculate xxxx, and finally xxxx.
- When the input is negative, we can directly return xxx.
- Write code fast, don't change it back and forth, or you will be labeled as not good at coding.
In fact, with the foreshadowing ahead, it is not difficult to write quickly. Because the above is actually about the idea, and you already have a good understanding of the algorithm by explaining the method by example.
But no problem with the idea does not mean that it can be written completely. The same can be written out completely does not mean that there is no need to scribble corrections. This requires everyone to outline the general framework of the code first.
A simple trick is: write code in modules, one function and one function . This reduces the likelihood of constant smearing and tinkering.
one example:
def solve(nums):
def check(mid):
# do something
def another_func():
pass
# ...
l, r = 0, len(nums) - 1
while l <= r:
mid = (l + r) // 2
check(mid)
Where solve is the main function, and check and another_func are the split functions.
- After writing the code, write a test first.
This not only reflects your good coding habits, but also helps you find out if there are any problems with your code writing.
Tip: You can substitute the examples you gave with the interviewer and the examples given by the interviewer to see if it is right. Because of the foreshadowing, this should be very fast.
one example:
def solve(nums):
def check(mid):
# do something
def another_func():
pass
# ...
l, r = 0, len(nums) - 1
while l <= r:
mid = (l + r) // 2
check(mid)
assert solve([1,2,3,4]) == True
assert solve([]) == False
# ...
Here we make an assertion using assert. Similar to how we test code after daily development.
Summarize
Finally, we will organize a flow chart for everyone to remember, and everyone can save the map for future use.
Finally, I hope that everyone can get their own information offers in the spring recruitment season. You are also welcome to join my spring recruiting group. Add me on WeChat and reply to the spring recruits to join the group.
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。