The five main points of the programming technology interview

Source: Internet
Author: User
Tags arithmetic

Solid basic knowledge, high-quality code, clear ideas, the ability to optimize the code, excellent comprehensive ability is a programming technical interview of the five main points.

Looking for a job has always been a hot topic. To find the right job, it is inevitable to have to go through multiple rounds of interviews. A programming interview is the most important part of a programmer's interview process. If you can fully display their ability in the process of programming interview, then get the desired offer is the right thing.

I have been in Autodesk, Microsoft and Cisco and other companies as software engineers, many times to accept other people's interviews, but also interviewed a lot of people. Summarize the experience of interviewing and being interviewed, I found that although the interviewer's background and personality are different, but they are concerned about the five qualities of the candidate: a solid foundation of knowledge, the ability to write high-quality code, analysis of the problem of clear thinking, can optimize time and space efficiency, including learning ability, communication skills, The ability of divergent thinking and so on.

A solid foundation of knowledge

Solid basic skills is to become a prerequisite for excellent programmers, so the interviewer's primary concern for the quality of the candidate is whether a solid foundation. Usually the basic skills in the programming interview link embodied in two aspects: one is the programming language, the second is the data structure and algorithm.

Each programmer should at least master the 1~2 programming language. The interviewer can see the proficiency of his programming language in terms of the code written during the interview and the follow-up questions. For most companies interviewing for C + + as an example, if a function needs to pass in a pointer, the interviewer may ask whether it is necessary to add a const to the pointer and add the const to the position of the pointer; If the write function requires that the parameter passed in is an instance of a complex type, Interviewers may ask what is the difference between an incoming value parameter or a reference parameter, and when to add a const to an incoming reference parameter.

The data structure is usually the focus of the programming interview process. Before attending an interview, the candidate needs to be proficient with the data structures such as lists, trees, stacks, queues, and hash tables, as well as their operations. If we pay attention to each major company's face questions, we will find that the linked list and two fork tree related problems are a lot of interviewers like to ask questions. This aspect of the problem seems simple, but the real master is also very difficult, especially for a few 10 minutes in the interview time to test the basic skills of candidates. If the candidate in advance of the linked list of insertion and deletion of the knot, the two-fork tree traversal method of the loop and recursive writing are familiar to the chest, then really to the interview will be easy.

Most companies require algorithms only to look up and sort. Candidates can understand a variety of search and sorting algorithms on the basis of the focus on mastering the binary search, merge sorting and fast sorting, because many of the interview questions are only variants of these algorithms. For example, move a number of numbers in front of a sorted array to the back of the array, and then ask how to find the smallest number in the array. The essence of this problem is to examine the two-point search. A handful of companies that value the algorithm, such as Google or Baidu, will also require candidates to master dynamic programming and greedy algorithms. If you are interested in this type of company, you should strengthen the practice of the relevant algorithm before you attend the interview.

High-quality Code

Only quality-oriented programmers can write robust and stable large software. In the interview process, the interviewer will always pay attention to the boundary conditions, special input and other seemingly trivial but essential important place, in order to analyze whether the candidate pay attention to code quality. Most of the time, the interviewer found that the candidate wrote the code can only complete the most basic functions, once entered a special boundary condition parameters will be riddled with errors and even the program crashes.

One question many candidates have been asked: Write a function that converts a string into an integer. This problem seems very simple, most of the graduates of computer science can use the code within 10 lines to achieve the most basic functions. But in the actual interview process, only one of the 10 candidates can pass the interview, because the vast majority of candidates can not fully consider a variety of special input, such as the input string contains a non-numeric symbol, at the beginning of the string sign, the string has a positive sign, but its position is not at the beginning of the string.

In addition, the interviewer expects the candidate to consider the boundary conditions, including 2147483647 (0x7fffffff,int can represent the largest positive integer) and -2147483648 (0x80000000,int can represent the smallest negative integer).

In addition to the boundary conditions and the lack of special input considerations, the interviewer has an intolerable error is the program crashes. During the interview, many candidates forget to do special processing of the null pointer and cause the program to crash. If the interview with the linked list, binary tree related topics, candidates must be particularly careful. Because there are usually a lot of pointer operations in the code for both topics, it is possible to manipulate the null pointer and crash the program if it is poorly considered.

such as a question: input a list of the head pointer and an unsigned integer k, output the list of the penultimate K node. Many people can think of two pointers to solve this problem: the first pointer moves the k-1 step on the list, while the first pointer and the second pointer move on the list. When the first pointer moves to the tail pointer, the second pointer points to the reciprocal K node. However, not every candidate can write the complete code according to the correct idea. Many candidates will ignore two possible: first, the input of the head of the list may be null pointer, the second is the number of nodes on the list may be less than K. Ignoring the two-point code is likely to crash, making it difficult to get the interviewer's attention.

To write robust high-quality code, you need to think about the test case before you write the code. Before you write the code, you need to think about all the boundary conditions and special input as test cases. When the code is written, you can use the test cases you have previously thought out to test the code you wrote, so that you will be able to discover and solve the problem before the interviewer. For example, the reciprocal K-junction of the linked list if you think of the input head pointer as null pointer and the total number of nodes on the list less than K of the two test cases, and after writing the code in the heart of the simulation of the operation of the code to ensure that the two test cases can be tested, then this round of interview must be able to pass.

A clear idea

Only clear thinking, candidates can be in the interview process to solve complex problems. Sometimes the interviewer will deliberately come up with some more complicated questions to examine whether they can form a clear idea and solve the problem in a short time. For a really complicated question, the interviewer doesn't even expect the candidate to give a complete answer in less than one hours, and he's more likely to be thinking clearly. Interviewers usually don't like candidates to start writing code before they have a clear idea, and the resulting code is easily confusing and riddled with errors.

A few simple ways for a candidate to help form a clear idea.

The first is to give a few simple concrete examples to understand the problem. When there is no problem in the hidden law, you can try to use 1~2 a concrete example of the process of simulation, so that may be a concrete example to find the abstract law.

Second, you can try to represent an abstract data structure with graphs. When you analyze topics related to linked lists and binary trees, you can draw their structural diagrams to simplify the topic.

Finally, you can try to decompose complex problems into a number of simple child problems, and then one by one to solve. Many of the ideas based on recursion, including partition and dynamic programming, are to decompose complex problems into one or more simple child problems.

For example, the problem of transforming a two-fork search tree into a sorted two-way list is complicated. Encounter this problem, might as well first draw 1~2 a specific two-fork search tree and its corresponding sort of two-way linked list, intuitively feel the binary search tree and the sort of two-way linked list of links. If you can't find the rule of transformation, you can see the whole binary tree three parts: root node, Saozi right subtree. When the transformation of the left and right subtree is resolved recursively, the linked list and the root node are linked to the transformation of the left and right subtree, and the whole problem is solved.

The ability to optimize your code

Good programmers haggle over time and space, and they are passionate about optimizing their code. When the interviewer's question has multiple solutions, he usually expects the candidate to eventually find the best solution. This requires candidates in the interviewer tips and better solution, not to give up thinking, but should try to find in time consumption or space consumption can be optimized place.

To optimize time or space efficiency, you first need to know how to analyze efficiency. Even with the same algorithm, the efficiency of implementing the different methods may vary greatly, and the efficiency of the algorithm and its code implementation can be analyzed. For example, the Fibonacci sequence, many people like to use the recursive formula F (n) =f (n-1) +f (n-2) solution. If you analyze its recursive call tree, you will find that a large number of computations are duplicated, and time efficiency is increased by the exponent of N. But if f (1), F (2) is first obtained, and F (3) is calculated according to F (1) and F (2), then we find F (4) based on F (2), F (3), and so on, and so on, we use a loop to find the f (n), which has a much better time efficiency of O (n) than the previous recursive method.

To optimize the efficiency of your code, you should also be familiar with the pros and cons of various data structures and choose the right data structure to solve the problem. We can use O (1) to complete the search in the array according to the subscript. This feature of the array can be used to implement a simple hash table to solve many interview questions, such as finding the first character in a string that appears only once. For example, to find the smallest number of k in n digits, a data container is needed to store K numbers. In this data container, we want to be able to quickly find the maximum value and quickly replace the number. On balance, we found that a two-fork tree, such as the largest heap or the red-black tree, is the ideal choice for implementing this data container.

To optimize the efficiency of the Code, but also to master the commonly used algorithms. The most commonly used algorithm in interviews is to find and sort. If you scan an array from beginning to end, you need an O (n) time to complete the lookup operation. But if the array is sorted, the application of the binary lookup algorithm can reduce the time complexity to O (Logn). Sorting algorithms can be used to solve other problems, in addition to sorting arrays. For example, the partition function in the Quick sort algorithm can be used to find the number of K in the number of N, which can be used in the time of O (n) in the array to find the number of occurrences more than half the length of the array. If the interview question is a problem that asks for the maximum or the minimum, you can try the dynamic programming method or greedy algorithm, such as using dynamic programming method to find the maximum and the contiguous sub array in the number group.

Excellent ability to synthesize

In the interview process, in addition to the presentation of their programming skills and technical skills, but also need to demonstrate their soft skills, such as communication skills and learning ability. As software systems become more and more large, software development has been a farewell to the era of singles, programmers and other people's communication becomes more and more important. In the interview process, the interviewer will observe the candidate in the introduction of project experience or algorithmic thinking, whether the point of view clear, logical clarity, and to determine his ability to communicate strength. In addition, the interviewer will be judged by the look and tone of the candidate's speech to determine whether he has a sense of teamwork. Usually interviewers don't like people who are arrogant or despise collaborators.

The IT industry updates knowledge quickly, so programmers only have a good ability to learn to keep abreast of the pace of change. There are usually two ways for interviewers to examine a candidate's ability to learn. The first approach is to ask what books the candidate has been reading recently, and what new technologies have been learned. The interviewer can use this question to understand the candidate's learning desire and learning ability. The second method is to throw a new concept, and then he will see if the candidate can understand the new concept and solve the problem in a relatively short time. For example, the interviewer asks the candidate to calculate the 1500th ugly number. Many people have never heard of the concept of ugliness. At this time, the interviewer will look at the face of the new concept of ugly, can not ask questions, think, and then ask the process, and finally find the law of the ugly number to find a solution.

Knowledge transfer ability is a kind of special learning ability. If we can move what we already know into other areas, it will be easier to learn new technologies or solve new problems. Interviewers often ask a simple question first, and then ask a complex question that is related to the simple problem ahead. The interviewer expects the candidate to get a hint of a simple problem and find a solution to the complex problem. For example, the interviewer first asks the candidate to write a function to find the Fibonacci sequence, ask a frog to jump the step problem: A frog can jump up to 1 steps at a time, can also jump up to 2 steps, I ask the frog jump on the N-level steps in total how many kinds of jump method. If the candidate has a strong knowledge transfer ability, it can be analyzed that the frog jump step problem is essentially a Fibonacci sequence of the application.

Many interviewers like to examine the candidate's abstract modeling ability and divergent thinking ability. The interviewer extracts problems from daily life, such as how to determine whether 5 cards are shun son, test candidates can abstract the problem with a reasonable data structure, and find the law to solve this problem. The interviewer may also limit the applicant's ability to use the usual methods, which requires the candidate to be innovative, able to open his mind to analyze and solve problems from multiple perspectives. For example, the interviewer asked the candidate not to subtraction arithmetic to achieve the addition of two integers. At this point the interviewer expects candidates to be able to open their mind and use bitwise arithmetic to add integers.

Summary

We can use the following figure to sum up the quality that the candidate needs to have.

As can be seen from the above picture, candidates need to be prepared before the interview, a comprehensive understanding of the basic knowledge of programming languages, data structures and algorithms. If you encounter a simple question during an interview, you must pay attention to detail to write complete, robust code. If you encounter a complex problem, the candidate can draw a picture, give specific examples to analyze and decompose complex problems, and so on to clear the way to start programming. In addition, the applicant should continue to optimize the time efficiency and space efficiency, and strive to find the best solution. During the interview process, candidates should also ask questions to clarify the requirements of the topic, performance of their communication skills. When the interviewer asked before and after the two questions have relevance, as far as possible to solve the problem before the migration to the back of the problem, to show their good learning ability. If you can do so, then it will be fruition for the candidate to get the right job through the interview.

Author He Haitao, Cisco Senior Software engineer, previously served in Autodesk and Microsoft. Focus on the development of c++/c# technology, and design patterns and project management is also interested.


This article is selected from the "Programmer" magazine 2011 10, more exciting content please pay attention to 10 issue magazine

"Programmers" magazine subscription Hot in progress

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.