Five key points of programming technology interview

Source: Internet
Author: User

Wen/He Haitao

Solid basic knowledge, high-quality code, clear thinking, ability to optimize code, and excellent comprehensive ability are the five main points of programming technology interviews.

Finding a job has always been a hot topic. To find your desired job, you will inevitably need to go through multiple rounds of interviews. Programming interview is the most important part in the interview process for programmers. If you can fully demonstrate your abilities in the programming interview process, it is a matter of course to get your favorite offer.

I have worked as a software engineer in Autodesk, Microsoft, Cisco, and other companies. I have been interviewed by others for many times, and I have also interviewed many people. Summing up the experience of the interview and the interview, I found that although the interviewer's background and personality are different, they all focus on the five qualities of candidates: solid basic knowledge; ability to write high-quality code; clear thinking during problem analysis; time efficiency and space efficiency can be optimized; comprehensive capabilities include learning, communication, and divergent thinking.

Solid basic knowledge

A solid basic skill is a prerequisite for becoming a good programmer. Therefore, the interviewer must pay attention to the qualities of candidates, that is, whether they have a solid foundation. The basic skills are usually embodied in two aspects: programming language and data structure and algorithm.

Each programmer must be familiar with at least 1 ~ Two programming languages. The interviewer's skills in programming language can be seen from the code written by the applicant during the interview and the follow-up questions. Take C ++ as an example. If the function needs to input a pointer, the interviewer may ask whether to add const to the pointer, what is the difference between adding const to different points of the pointer? If the parameter to be input by a written function is a complex instance, the interviewer may ask what is the difference between the input value parameter or the reference parameter, when do I need to add const to the passed reference parameter.

Data structure is usually the focus of the programming interview process. Prior to the interview, you must be familiar with data structures and their operations, such as linked lists, trees, stacks, queues, and hash tables. If we pay attention to the interview questions of major companies, we will find that the linked list and binary tree related questions are a lot of questions that interviewers like to ask. This problem seems simple, but it is not easy to grasp. It is especially suitable for testing the basic skills of candidates in just a few minutes of interview. If the applicant knows the insertion and deletion nodes of the linked list in advance, and he is familiar with the loop and recursive writing methods of the binary tree traversal methods, then the interview will be easy enough.

Most companies only require search and sorting algorithms. On the basis of understanding various search and sorting algorithms, candidates can focus on Binary Search, Merge Sorting, and quick sorting, because many interview questions are just a variant of these algorithms. For example, move the first number of the sorted array to the end of the array, and then ask how to find the smallest number in the array. The essence of this question is to examine binary search. A few companies that place great importance on algorithms, such as Google or Baidu, also require candidates to be proficient in Dynamic Planning and greedy algorithms. If you are interested in this type of company, you should strengthen the exercises on related algorithm questions before attending the interview.

High-quality code

Only quality-oriented programmers can write robust and stable large-scale software. During the interview, the interviewer will always pay special attention to boundary conditions, special input, and other seemingly subtle but essential aspects to analyze whether the applicant pays attention to the quality of code. Most of the time, the interviewer finds that the code written by the applicant can only complete the most basic functions. Once a special boundary condition parameter is entered, it may cause hundreds of errors or even program crashes.

A question many applicants have asked: Write a function and convert the string to an integer. This question seems very simple. Most computer graduates can use less than 10 lines of code to implement the most basic functions. However, in the actual interview process, only one of the ten candidates can pass the interview, because the vast majority of candidates cannot fully consider various special input, for example, the input string contains non-numeric symbols, positive and negative signs at the beginning of the string, and positive and negative signs in the string, but its position is not at the beginning of the string.

In addition, the interviewer also hopes that the applicant can consider the boundary conditions including 2147483647 (0x7fffff, int can represent the maximum positive integer) and-2147483648 (0 × 80000000, int can represent the minimum negative integer ).

In addition to insufficient boundary conditions and special input considerations, an intolerable mistake for the interviewer is program crash. During the interview, many candidates will forget to perform special processing on the NULL pointer, resulting in program crash. If you have questions related to linked lists and Binary Trees during the interview, you must be very careful. Because the code corresponding to these two kinds of questions usually has a lot of pointer operations, if you are not considerate, it is possible to operate on the NULL pointer and cause the program to crash.

For example, enter the head pointer of a linked list and an unsigned integer k to output the last K node of the linked list. A lot of people can think of this problem with two pointers to solve: The first pointer first move the K-1 step on the linked list, at the same time let the first pointer and the second pointer move on the linked list. When the first pointer moves to the end pointer, the second Pointer Points to the last K node. However, not every candidate can write the complete code based on the correct idea. Many candidates ignore two possibilities: first, the input head pointer of the linked list may be a null pointer, and second, the number of nodes on the linked list may be less than K. Code that ignores these two points may crash, making it difficult for the interviewer to favor.

To write robust and high-quality code, you need to think about test cases before writing code. Before writing code, consider various boundary conditions and special input as test cases. After the code is written, you can use the previously designed test cases to test the code you have written, so that you can discover and solve the problem before the interviewer. For example, if you think of the test case that the input header pointer is a null pointer and the total number of nodes on the linked list is less than K, in addition, after writing the code, you can simulate the code running process in your mind to ensure that you can pass the tests of the two test cases. This round of interviews will inevitably pass.

Clear thinking

Only with clear thinking can candidates solve complicated problems during the interview process. Sometimes the interviewer will intentionally come up with some complicated questions to check whether they can form a clear idea and solve the problem in a short time. For complex questions, the interviewer does not even expect the applicant to give a complete answer within less than an hour of the interview. What he cares more about is whether the applicant has a clear idea. Usually, the interviewer does not like the candidate to write code rashly without forming a clear idea. The code written in the result is prone to logic confusion and errors.

Candidates can use a few simple methods to help them form a clear idea.

The first is to give a few simple examples to help you understand the problem. Try to use 1 ~ Two specific examples are used to simulate the operation process, so that the abstract law can be found through specific examples.

Next, we can try to use graphs to represent abstract data structures. When analyzing questions related to linked lists and binary trees, you can draw their structure to simplify the questions.

Finally, we can try to break down complicated problems into several simple sub-problems and solve them one by one. Many recursive-based ideas, including the divide and conquer method and dynamic programming method, are to break down complicated problems into one or more simple subproblems.

For example, the problem of converting a binary search tree into a sorted two-way linked list is very complicated. If you encounter this problem, first draw 1 ~ Two specific binary search trees and their corresponding sorted two-way linked lists intuitively show the links between the Binary Search Tree and the sorted two-way linked list. If the conversion rule cannot be found at once, the entire binary tree can be seen in three parts: the root node, the left subtree, And the right subtree. After the two subproblems of conversion left and right Subtrees are solved recursively, the linked list and root node obtained from the conversion left and right Subtrees are linked, and the whole problem is solved.

Code optimization

Excellent programmers are eager to constantly optimize their own code. When the interviewer has a variety of solutions to the questions, usually he will expect the candidates to eventually find the optimal solution. This requires that you should not give up thinking when the interviewer prompts that there is a better solution. Instead, you should try to find a place that can be optimized in terms of time consumption or space consumption.

To optimize the time or space efficiency, you must first know how to analyze the efficiency. Even for the same algorithm, the efficiency of implementation using different methods may vary greatly, so it is necessary to analyze the efficiency of the algorithm and its code implementation. For example, for the Fibonacci series, many people prefer to use the recursive formula F (n) = f (n-1) + f (n-2) to solve. If we analyze its recursive call tree, we will find that a large number of computations are repeated, and the time efficiency increases exponentially with N. However, if F (1) and F (2) are obtained first, then f (3) is obtained based on F (1) and F (2). Then, according to F (2) F (3), F (4), and so on, use a loop to find F (n). The time efficiency of this calculation method is only O (n ), it is much better than the previous recursive method.

To optimize code efficiency, you must be familiar with the advantages and disadvantages of various data structures and be able to select an appropriate data structure to solve the problem. We can use O (1) to complete the search based on the subscript in the array. This feature of the array can be used to implement a simple hash table to solve many interview questions. For example, you can find the first character that appears only once in the string. For example, to find the minimum k Number of N numbers, a data container is required to store K numbers. In this data container, we hope to quickly find the maximum value and quickly replace the number. After balancing, we found that the binary tree, such as the largest heap or red/black tree, is an ideal choice for achieving this data container.

To optimize code efficiency, you must master common algorithms. The most common algorithms for interviews are search and sorting. If an array is scanned sequentially from start to end, it takes O (n) Time to complete the search operation. However, if the array is sorted, the time complexity can be reduced to O (logn) by applying the binary search algorithm ). In addition to sorting the array, the sorting algorithm can also be used to solve other problems. For example, the partition function in the quick sorting algorithm can be used to find the number k in N numbers, so that O (n) can be used) in the array, find the number that appears more than half the length of the array. If you want to obtain the maximum or minimum values, you can use dynamic programming or greedy algorithms. For example, you can use dynamic programming to obtain the maximum and number of consecutive subarrays in an array.

Excellent comprehensive capabilities

In the interview process, in addition to showing your programming skills and technical skills, you also need to show your soft skills, such as communication and learning skills. As the scale of software systems grows, software development has already left the age of standalone, so it is increasingly important for programmers to communicate with others. During the interview, the interviewer will observe whether the applicant has a clear viewpoint and logic when introducing the project experience or algorithm ideas, and then judge the strength of his communication skills. In addition, the interviewer will also judge whether the candidate has a sense of teamwork from the manner and tone of his speech. Usually, interviewers do not like people who are arrogant or despise collaborators.

Knowledge in the IT industry is updated quickly, so programmers can keep up with the pace of Knowledge replacement only when they have good learning ability. Usually, the interviewer has two ways to test the applicant's learning ability. The first method is to ask the applicant what books he has recently read and what new technologies he has learned. The interviewer can use this question to learn the desire and ability of the applicant. The second method is to throw out a new concept. Next, he will observe whether the applicant can understand the new concept and solve related problems in a short time. For example, the interviewer asks the applicant to calculate 1,500th ugly figures. Many people have never heard of the concept of ugly data. At this time, the interviewer will observe the new concept of the ugly number, whether the applicant can go through the process of asking questions, thinking, and asking questions, and finally find the law of the ugly number to find a solution.

Knowledge migration capability is a special learning capability. If we can migrate our knowledge to other fields, it will be easy to learn new technologies or solve new problems. The interviewer often asks a simple question first, and then asks a complicated question that is related to the previous simple question. At this time, the interviewer expects the applicant to get inspiration from simple questions and find a solution to complicated problems. For example, the interviewer first asks the applicant to write a function to calculate the Fibonacci series and then asks another question: a frog can jump to level 1 or Level 2 at a time, how many methods are there for this frog to jump N-level steps? If a candidate has a strong knowledge migration capability, he or she can analyze the progress jump problem, which is essentially an application of the Fibonacci series.

Many interviewers also like to examine the applicant's abstract modeling and divergent thinking abilities. The interviewer extracts problems from his daily life, for example, how to judge whether five playing cards are good or not, examine the applicant's ability to abstract the problems and express them in a reasonable data structure, and find the rules to solve the problem. The interviewer can also restrict the use of regular methods. This requires the applicant to be innovative and be able to analyze and solve problems from multiple perspectives. For example, the interviewer asks the applicant to add two integers without the addition, subtraction, multiplication, division, and four arithmetic operations. At this time, the interviewer expects the applicant to open his mind and use bitwise operations to add integers.

Summary

We can summarize the qualities that candidates need.

It can be seen that candidates need to make adequate preparations before the interview, and have a comprehensive understanding of the basic knowledge of programming languages, data structures and algorithms. If you encounter a simple problem during the interview, you must pay attention to the details to write complete and robust code. If you encounter a complex problem, you can clear your mind and then start programming by drawing a picture, giving examples to analyze and breaking down complicated problems. In addition, the applicant should constantly optimize the time efficiency and space efficiency, and strive to find the optimal solution. In the interview process, the applicant should also take the initiative to ask questions to clarify the requirements of the questions, to express their communication skills. When the two questions asked before and after the interviewer are relevant, try to migrate the ideas for solving the previous questions to the following questions to demonstrate their good learning ability. If you can do so, it will be easy to get your favorite job through the interview.

He Haitao, Cisco Senior Software Engineer, previously worked in Autodesk and Microsoft. Focus on the development technology of C ++/C # And be interested in the design mode and project management.

Http://www.programmer.com.cn/8435/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.