With the spring recruitment of major companies, many people are taking action. I am honored to be able to join Baidu and share my experience with you. Since my interviews are mostly for large companies, I have naturally made preparations in this respect. Therefore, this summary is not necessarily suitable for students who want to go to a startup company. In addition, because experience is a highly subjective thing, and the author’s level is limited, so if there is not recognized, I hope you laugh and forget.
I’ll venture to share what I’ve learned from preparing for and attending an interview, what I’ve thought about the interview, and some tips that might be useful to you. At the end, there is a gift package to help each reader find their desired job.
What is an interview
Some people may put too much emphasis on the interview, thinking that they can get into the big factory after the interview, and have both technology and wealth…
In my opinion, the interview is less dramatic (sorry for the clickbait) and it’s actually a great opportunity for you and the interviewer to get to know each other, as well as get a sense of what your future job might be.
The interview itself is not a complete evaluation of a person’s strength. Those who pass the interview may just encounter familiar problems in the interview, and those who fail the interview may also be the problems of the interviewers themselves. Not every interviewer has the ability to objectively evaluate others.
In other words, if you fail the interview, the interviewer may not find your talent, and if you pass the interview, it does not mean you are qualified for the job, because you are not responsible for answering the interview questions every day after you enter the company!
So in this sense, an interview is a bit like a blind date. You are satisfied with me, I am satisfied with you, bastard pair of mung bean — have a liking for an eye, that hit it off immediately, otherwise go their separate ways. I’d really like to do more interviews (which is not always possible) so that everyone has enough time to get to know each other and decide whether to stay or not.
In some online interviews, there are some methods of “pretending to be forced”, and the so-called “interview skills”, which I do not agree with. Skills need to have, this is in order to let you better show their own, rather than cheat, vexatious, out of thin air. I want to show my true self. If the interviewer doesn’t agree with me, it means we don’t have fate, or my ability is not enough.
What should I prepare for the interview
After one of her friends was rejected from an interview with Ali, the interviewer said, “… The basic computer skills, the basic programming skills…” . But this general answer is not the answer we hoped for. What is the basis?
As an iOS developer, my understanding of the basics is the operating system, the network, and the algorithm. Different development directions may have different focuses, but that’s basically the basics. I don’t recommend going to an online tutorial to learn the basics, because anything that can be explained in a few short articles is not basic, at least not one I’ve seen.
I don’t know how many readers and I have such a problem: “I know something is very important, so I went to Baidu to check the information, but the quality of the article is very poor, the correct rate is not guaranteed”. This is actually normal, good articles are generally placed on the personal blog of good authors, which is exactly the blind area of search engines, so generally can only search CSDN, blog garden such places articles. Naturally, there is no guarantee of quality.
With that in mind, the review materials at the end of this article include books to learn the basics and, if you happen to be an iOS developer, some of the high-quality articles I’ve collected are guaranteed to be correct (except for those I’ve written).
In addition to preparing general basics, a resume is also an important part of the process. Always admire tang Qiao teacher’s ape question bank, but the resume is too bad, have not received the interview invitation. Later, after a good resume change, there is no such problem. Two articles on resume writing are recommended: how to write a resume for Internet companies and a resume template for programmers. You can also take a look at my resume. It’s unimpressive.
Finally, of course, prepare the basics of the job. As an iOS developer, Swift has been around for almost two years, but the move to Swift by big companies hasn’t been obvious yet, so Objective-C is almost a must, and Swift isn’t necessarily a plus. IOS knowledge is also a must. Although the job listing says that if you have a solid foundation, you can have zero iOS knowledge, but the reality is often cruel.
My interview experience
Pull so much, finally enter the topic, share my interview experience. The problem is as follows, and behind the broken line is a simple solution.
baidu
One side: about 1.5 hours
First, there are four algorithm questions:
- How can swap(a, b) be implemented without temporary variables – with addition or xOR
- Find a number in a 2d ordered array
- In the 100 million level log, look for the top 10 login users — use a hash table to save the login times and IDS, and then use a red-black tree to save the top 10 numbers. Offer 30
- A brief description of the sorting algorithm — quicksort,
partion
Function principles, heap sorting (unstable), merge sort, radix sort.
Then there is a intelligence question, not complete answer out, as if the impact is not very big.
Finally, the questions related to iOS are very open, and they are all about their own understanding:
- Tell me what you think of OC
load
Methods andinitialize
Similarities and differences in methods. Will a method that does not implement a subclass call its parent class? - Tell me what you think about blocks. Three types of block, the stack automatically copy to the heap, block attribute modifier is copy, circular reference principle and solution.
- Tell me what you think of Runtime. — how to find the cache when the method is called, how to find the method, how to forward when the method is not found, the memory layout of the object.
- Tell me about your understanding of MVC and MVVM. — MVC’s C is too bloated and can be merged with V to become V in MVVM, which is used to convert M into data V can use.
- Talk about tuning UITableView. — One is to check where performance is affected through Instruments, and the other is to estimate height and cache when Runloop is idle.
- Talk about your understanding of ARC. ARC is done by the compiler and relies on reference counting. Talk about a few memory management strategies for attribute modifiers and when memory leaks occur.
On the one hand, the questions were very basic, mostly algorithms and Objective-C, and because I was well prepared, I answered about 80% of the questions. About a week later, I had a second interview.
Second interview: about 0.5 hours
The second interview was abrupt, with a brief introduction and three questions:
- What are wild Pointers, and when do you have wild Pointers in iOS development? A pointer to free memory is not nil, but it is a pointer to memory that has been freed.
- Introduction to block. I asked the interviewer to remind me when there would be wild Pointers. When he said block, I said I still don’t know, only that block has circular references. And that brings us back to one side of the question.
- Talk about how you optimized UITableView. — It’s one side…
I passed, but the fact that I was almost asked one more time made me feel that the other person was not serious.
Three sides: Beijing Onsite, about 2.5 hours
The first is to give an hour, handwritten algorithm two algorithm problems. The next question is about the TCP handshake. Finally asked OC some detailed questions.
netease
The written test
It’s a hodgepodge of computing, operating systems, networking, mobile development, algorithms, etc. Not difficult, visual is to eliminate fish in troubled waters, do not list the problem, the algorithm has three questions, directly online to write (no IDE said very sad) :
- A very long question, read for a long time to read to understand, visual is DFS, but finally ran out of time, wrote a train of thought.
- Change a string like “www.zhidao.baidu.com” to “com/baidu/zhidao/ WWW “. — Offer. — Offer.
- Find all subarrays of an array and a value, such as an array is
,5,10,2,3 [5]
The sum of four subarrays is 15, for example[5, 10]
.[5, 10]
.[10, 2, 3]
.,5,2,3 [5]
. So this is a simple recursion, there are two cases, the number at the current position is in the subarray, and the number is not in the subarray.
One side
All are iOS problems, may be that the algorithm has been faced:
- Introduction to block. — I mentioned that blocks on the stack are automatically copied to the heap under ARC. The interviewer asked me whether I supported this feature since iOS 4 or 5. I didn’t know, since I didn’t study OC history.
- What optimizations will ARC make to the code? , such as
NSString *s2 = s1; s2 = nil
Such a statement, there may not beretain
εrelease
Methods. - Introduce MVVM and RAC. — I may have used RAC in a corner of my resume, and it was found out, and I talked about it, and the interviewer asked me how to do bidirectional data binding.
bind
The function πππ - Describe which open source libraries you have used. — For navigation and SnapKit, AFNetWorking, MKNetworkKit, Alamofire, Mantle, SDWebImage
- If you were asked to write, could you do it? — Of course not. Or would I have an internship?
- Have you read the source code for a library? The only way to use runloop is to ensure that the background thread is running all the time.
- Why should SDWebImage decode the image after downloading it? — At that time, the interviewer was very nice to explain, said that the PNG file to create a memory map, currently do not understand, have time to research.
Originally thought the face so bad affirmation is to hang up, did not think or over one side. Less than an hour later, HR called and made an appointment for a second interview in two days.
Second interview
Pure mathematics and algorithms:
- The output of the following code is:
int main(a) {
int a[5] = {1.2.3.4.5};
int *ptr=(int *)(&a+1);
printf(" % d, % d ", * (a +1),*(ptr- 1));
}
Copy the code
The answer is 2 and 5. A is a pointer to the first element of the array, and a + 1 is a pointer to the next element, so the asterisk evaluates to 2. Ampersand a is a pointer to an array, ampersand a + 1 is a pointer to the array after the array, and then converted to int * is a pointer to the number after the number 5. Minus one is a pointer to five, so the asterisk evaluates to five.
- If it doesn’t rain on the first and second days, there is a 30% chance that it will rain on the third; If it rains on either day, there is a 60% chance that it will rain on the third. If it doesn’t rain on Monday or Tuesday, then the probability of rain on Thursday is ___.
Easy probability, the answer is: 30% * 60% + 70% * 30% = 39%
- A small group obsessed with poker likes to count by 23456789TJQKA. After A is 22,23… ,2A,32,… ,AA,222,… And so on. Write a program in C/C++ or Java that converts the string representation to a string representation of a decimal integer. Where the 2 of the counting method corresponds to the decimal 2 and then increments. Char * pokToDec(char *)
My solution is to convert the number to a char star, something like hexadecimal to adecimal, and then convert it to a char star.
And then it seems to have no results, maybe the programming implementation is too bad?
Other interview questions I know
Ali side:
MVC
What advantages does it have? How do modules communicate with each other? For example, how do I notify the Model after clicking a Button?- Two lists of infinite length (that is, possibly with a loop) determine if they intersect
UITableView
Correlation optimization ofKVO
,Notification
,delegate
Pros and cons, efficiencies, and usage scenarios- How to Manually notify
KVO
- Objective – in C
copy
methods - The runtime,
SEL
εIMP
The difference between autoreleasepool
Scenarios and principles of theRunLoop
The implementation principle and data structure, when will be usedblock
Why do circular references exist- use
GCD
How to achieve this requirement: A, B, C three tasks concurrent, after the completion of task D. NSOperation
εGCD
The difference betweenCoreData
How to deal with multithreading problems- How to design image cache?
- Have you ever designed your own network controls?
Ali second side:
- How to judge someone
cell
Whether to display on the screen - The difference between processes and threads
TCP
δΈUDP
The difference betweenTCP
Flow control- The difference between arrays and lists
UIView
The life cycle- If page A goes to page B, A’s
viewDidDisappear
Method and BviewDidAppear
Which method is called first? block
Circular reference problemARC
The nature ofRunLoop
How does it sleep?Autoreleasepool
When is it released and in what context?- How do I find the first distinct character in a string
- How does the hash table handle conflicts
The interview to harvest
1. How to answer the algorithm question
The interviewer may ask you about an algorithm you’ve never heard of, but you shouldn’t try to think it over with the interviewer first. You should know that understanding complex questions through communication is also a kind of ability. In the process of communicating with the interviewer, you can not only figure out what the questions really mean, but also show your good communication skills. So don’t let this great opportunity go to waste because you’re nervous or shy.
Some of the topics are familiar, but I have no idea. Tell the interviewer to give me some time to think about it. Then take your time, don’t panic, pretend he doesn’t exist, get out a pen and paper and do the math (which speaks to the importance of headphones). You must have a firm belief: “any slightly difficult algorithm problem, unless done, or it must be time to think”. So spend your thinking time wisely. If you can’t think of more than ten minutes, you can give up directly.
Sometimes an interviewer will ask for online programming, and trust me, he won’t get bored and stare at your code. Interviewers are usually busy and have their own work to do, so just use your IDE. Online programming tends to be a moderately difficult problem, so don’t scare yourself. Also be careful to format your code properly, make appropriate comments, write test cases in advance, and at least show your good programming habits to the interviewer, if not to solve the problem.
2. How to deal with problems that can’t be solved
This question could be a deliberate attempt to be vague and measure your communication skills, or it could be an unintentional question or a misinterpretation of your interpretation. In either case, you should communicate with your interviewer until you understand what the interviewer is asking you, rather than saying a bunch of useless things as you understand them.
For example, an interviewer might ask an algorithm question: “How do you tell if two lists of infinite length intersect?” . There are different interpretations of “infinite length”, but if there really are an infinite number of nodes, then obviously the problem cannot be solved. But if the list just had a loop, then we could work it out. If the interviewer meant the list to have links, but you misinterpreted it to have an infinite number of nodes, you will fail to answer the question. And it’s not a lack of ability, it’s a failure of communication, and that’s the “tip” I want to share.
There are also questions that, although you have not been exposed to them, you can reasonably assume because you have thought about similar problems or situations. For example, if the interviewer asks, “What optimizations will ARC make to the code?” . We know that the essence of ARC is to insert methods like retain and release where appropriate, so it’s worth thinking about it from that perspective.
Obviously it is not necessary to perform retain and release separately, so we can construct an example:
NSString *s1 = @"hello";
NSString *s2 = s1;
NSString *s2 = nil;
Copy the code
Since we haven’t really practiced this kind of question, we can politely say, “From what I can gather, there may be…” .
3. How to deal with problems that are really impossible
Admit when you don’t have a problem. If it’s a basic question, like how do you implement a hash table, and you say no, the interview could be in jeopardy. If it is a difficult question, it is wise to admit that you will not answer it. After all, no one is perfect, and a question does not negate a person’s ability completely.
But a worse situation is when a candidate is nervous and worried about the consequences of failing to answer the interviewer’s question, so he or she tries to be perfunctory. For example: “I’m guessing it’s XXX”, “I think it could be…” “, “I have tried this, is not XXX?”. Want to know, at this time of you, because of nervous, in the state of mind has lost to the interviewer, what’s more, the interviewer asked you the question must be he is sure, you think at this time you will have a few stubborn to win?
So, when the interviewer asked me for the details of heapsort, SINCE I had forgotten how heapsort works, I simply told him THAT I couldn’t remember. Another example of throwing in the towel was when the interviewer asked me how to implement two-way binding in RAC. I told him that it was a demo I had written when I was studying, because I didn’t use it very often and I only remembered some simple concepts.
Finally, it is necessary to maintain a steady state of mind: “Try your best during the interview, and it is normal to encounter problems that you will not have.” If the candidate answers all the questions correctly, it is inevitable that the interviewer will feel a little awkward, and there may be other emotions. Therefore, we have to do is to show their ability to the interviewer, do not arrogant and impatient.
4. Prepare for the mace
In addition to being able to answer the interviewer’s questions, I recommend preparing one or two killer topics. The so-called assassin’s mace has at least the following characteristics:
- You tested it yourself. Practice is the only criterion for testing truth. Data can’t lie.
- The problem is deep enough. One interview may be with your immediate boss, and a second interview is usually about changing levels. Your depth must be far more than other interviewers, let one side of the interviewer feel that they are not fully confident, let the second interview interviewer think that this is a good topic, their own staff are not necessarily able to have so original and profound insights.
- Your understanding of the problem is deep enough, both in breadth and depth.
Take the example of UITableView tuning in iOS, which I think I have a fair understanding of, for those of you who are iOS developers: UIKit performance tuning combat, while I also carefully studied sunnyxx great god to optimize UITableViewCell height calculations those things.
This is a topic that usually requires careful study of the official documentation, and iOS developers can also watch WWDC videos and spend plenty of time summarizing them. For example, IT took me at least three days to write this article, including a whole day on the first day of the Chinese New Year.
Since there are not many of these topics, you can prepare one or several, during the interview can consciously guide the interviewer to these topics, so as to fully show yourself.
5. State of mind
Usually, the results of the interview will be known within one to three days. Some interviewers will tell you you’ve passed on the spot, while others will tell you a few hours after the interview.
But sometimes, for some reason (I don’t know… Busy, maybe?) You can’t get the result of the interview. In this case, you can choose to wait patiently and be informed to send an email directly to HR or internal tweeters. If you don’t receive an announcement within three days of the interview, you can either send an email to ask or wait.
Review the information
For those of you who have read this paragraph, thank you for your patience in listening to my nonsense for so long, and send me a wave of carefully organized dry goods and materials. Can’t say completely wrong, but should be more reliable than their own to check. It mainly involves algorithm, network, operating system, Objective-C and iOS. If you’re not an iOS developer, the first three sections will help you somewhat.
algorithm
This section is divided into the following sections: strings, arrays and lookups, linked lists, trees, and other basic issues.
In general, algorithmic problems can be divided into the following three categories:
- Basics: Even for beginners, you can see the idea at first glance, but you need to pay attention to the details when you implement it.
- General questions: These questions usually fall into one of the above categories and require the candidate to master some common ideas, such as recursion, dynamic programming, BFS/DFS, double pointer, binary search, etc. Or directly investigate the use of data structures, such as: hashes, stacks and queues, lists, and so on. If you have these basic knowledge, this kind of problem can usually be solved relatively quickly.
- Advanced questions: these questions are similar to ordinary questions, but you need to have the corresponding knowledge accumulation in advance, otherwise it is difficult to directly see the nature of the problem.
- Difficult problem: this kind of problem is strange, after solving it can not give other problems too much help, if the time is tight can temporarily give up.
Generally speaking, difficulty of a kind of question is not big, review briefly before interview, be careful and careful when interview, comprehensive thinking can. Questions two and three are important and need to be prepared in advance. The fourth type of questions usually occurs less frequently, and even if they are not done, the negative impact on the final evaluation is not as great as the first three types.
If time is sufficient, I suggest reading ** “Sword Point Offer” ** and cooperating with Leetcode to consolidate my knowledge. In my interview process, many original questions or variants of the book appeared, and I believe that the algorithm did not affect my performance in any interview. If time is tight, you can also just complete my list of classic questions, with my classification of the question type marked in “[]”, and asterisks indicating that the question occurred in the actual interview.
PS: Recently, some friends were asked about the implementation of hash table. This can be understood as algorithms, or it can be classified as computer fundamentals. In general you need to understand at least the characteristics of hashes and two ways of resolving conflicts: zip and open addressing.
string
- [3] Longest callback substring
- [3] Longest non-repeating substring
- [1*] Convert a string to a number
- [4] KMP algorithm
- [2] Full array of strings
- [2*] Flips the string
Dynamic programming
- [2] The backpack problem
- [3] The largest sum of contiguous subarrays
- [4] Simple regular expression matching
An array of
- [3] Find the median of two equal-length, ordered arrays (dichotomy)
- [4] Find the median of two unequal and ordered arrays
- [3] Rotate the array to find the minimum value, [3] rotate the array to find the existence of a value (dichotomy)
- γ4*γ In each row from left to right and each column from top to bottom, determine whether a certain number exists.
- [3*] A number that occurs more than half the time in an array
- γ3*γ The KTH largest number (extension: the largest k number)
- γ3*γ The number of times a number appears in an ordered array (hint: use binary search)
The list
- [2] Reverse the linked list (use both recursive and iterative solutions, understand the head interpolation method)
- [3] Delete the current node of the linked list
- [3] Delete the KTH node
- [1] Merge two ordered lists
- [4] Replication of complex linked lists
- [2*] Determine whether the linked list has a loop
- [3*] The first common node of two linked lists (tip: Consider the case of a linked list with a loop)
- [3] Delete duplicate nodes from the linked list
The tree
- [3] The binary tree was reconstructed according to the results of middle order and post-order traversal. [3] The binary tree was reconstructed according to the results of middle order and pre-order traversal
- [2] Flip binary trees
- [2] Print binary trees from top to bottom (BFS idea)
- γ3γ Determine whether an array is the result of binary tree traversal.
- [3] The path to a value in a binary tree
- γ3*γ The next node in a binary tree
The stack
- [2] Queue is implemented with two stacks. [2] Stack is implemented with two queues
- [2] To implement a stack, you can find the minimum value in the stack in constant time
- γ3γ Judge whether the stack of pressure stack, the stack of bullets sequence is legal (sword refers to offer 第 22 ι’)
The sorting
Understand the time and space complexity, stability and implementation principles of the following sorts
- Merge sort, extension: Find the number of reverse pairs in an array
- Quick sortKey points:
partion
Implementation of function - Heap sort
- When the range of array elements is known, consider cardinality sort and bucket sort
An operation
- [2] Given a decimal number, find how many 1s (n &= n – 1) there are in its binary representation
- [3] Given an array in which all numbers appear an even number of times, but only one appears once, find the number
- [4] Given an array in which all numbers appear three times but one appears once, find the number
- [3] Given an array where all arrays appear an even number of times, but only two numbers appear once, find the two numbers
The network layer
The emphasis is slightly different depending on the job you’re interviewing for. For iOS and Android developers, HTTP is a little less popular, and TCP and UDP are more popular. UDP basically just looks at the difference between TCP and UDP.
Of course, there are some common basic problems, such as Cookie and Session inspection, POST and GET inspection, simple understanding of HTTPS and so on. These issues are summarised briefly on my blog.
Some materials are summarized. The larger the number, the longer the length, the longer the time, the more difficult, and the more detailed. Broken line indicates how long it is expected to take to read.
- My six summaries ββββ in less than a week
- [book] Diagram TCP/IPββββ half a month
- γ book γTCP/IP detailed explanation ββββ not read, feel at least a month
- [book] TCP/IP protocol cluster ββββ not read, feel at least a month
Reading books alone won’t help. It’s easy to get confused when asked practical questions. Here are some of the questions I summarized:
- What is the difference between TCP and UDP?
- How do routers and switches work, what protocols do they use, and on what layer are they located?
- Describes the process of three-way handshake and four-way release of TCP.
- How does TCP implement traffic control and congestion control?
- Why is there a three-way handshake to establish a connection? How about two? What happens if the third handshake fails
- What can I do if the fourth handshake fails when I close the connection?
- How do you understand layering and protocol?
- The difference between GET and POST in HTTP requests, and between Session and Cookie.
- Talk about your understanding of HTTP 1.1, 2.0, and HTTPS.
Operating system and compilation
I’ve been asked very few OS questions, so I’ve just summarized what I think are important questions. For more information on this section, it is recommended to read ** Self-cultivation for Programmers, or if time is limited, you can read my Reading Notes on Self-cultivation for Programmers ** and consider these questions:
- How does source code become executable, and what does each step do? (Precompilation, lexical analysis, syntax analysis, semantic analysis, intermediate language generation, object code generation, assembly, linking)
- What is the relationship between the application layer, API, runtime, system call, and operating system kernel?
- What is a virtual memory space and why do you have a virtual memory space?
- What do static and dynamic links mean, and how do they work?
- What is the structure of the executable? (What are the sections?)
- How does it load into memory, why does it fragment, why does it page, what are the page errors?
- What is the memory pattern of the process? (Heap, stack, global/static area, code area, constant area)
- The difference between heap and stack, the relationship between function call and stack
- The difference between processes and threads
- The difference between asynchronous and synchronous, serial, concurrent and parallel
- Does multitasking speed up concurrent tasks (no, it’s slower, there’s threading overhead)
- That data can be shared between multiple threads
- How do processes communicate with each other
- Introduces several locks, their uses and differences
For more information on multithreading, it is recommended to read the first part of this article, Multithreaded Programming for iOS — SUMMARY of GCD and NSOperation.
For articles on operating systems and compilation, in addition to reading the original book and my reading notes, you can also read this article, Modify a Number to Crack An Application on the Mac.
OC
The first two essential god books must be read. One is Effective Objective-C 2.0 by OC, titled “52 Effective Ways to Write High-quality iOS and OS X Code.” Another book: Advanced Programming in Objective-C. The former covers the details of OC, while the latter focuses on ARC, Block, and GCD.
Just reading and not thinking enough can easily make you confused in an interview, so I suggest you try to answer the interview question once and read the following summary article in no particular order of importance:
- Detecting memory leaks
- Principles of KVO and KVC, advantages and disadvantages of KVO, Notification, Delegate, most recommended official documents
- The GCD and NSOperation
- Runtime
- block
- Atomic thread safety, @synchronized
- Object depth copy
- Hire a solid iOS
- Messaging mechanism
- In-depth understanding of objective-C: Category
The eighth article is highly recommended. After finishing the above topics, you should be able to deal with most OC problems.
The iOS development
- RunLoop
- Optimized the asynchronous loading of Cell images
- Implementation of iOS functional programming && Responsive programming concept
- Memory demon drawRect
- UIKit performance tuning (mainly UITableView)
- Optimize the UITableViewCell height calculation for those things
- High-performance picture architecture and design
- Lightweight view controllers
- The lifecycle of UIView
- Efficient rounded corners
- Event delivery and response mechanisms
- Get started with ReactiveCocoa and MVVM
It’s important to understandrunloop
It is not just a simple concept of “running laps”, many problems are actually related to it, I suggest you read the summary of Ibireme carefully
Other side by
- How did I get offers from Both Alibaba and Tencent
- Junior students get internship offer interview experience of Alibaba and Baidu
- 2016 January TX electrical surface problem