ByteDance tested the face-to-face experience. After listening to him, I was so nervous that I sweated

Under the severe situation of this year's autumn recruitment, a friend of mine went directly to the byte interview without the written test. On the night he received the interview invitation, he was so excited that he didn't fall asleep all night!

foreword

 

There are a lot of blah blah blah blah, talk about what code you wrote in school, what awards you won, whether you have won a scholarship, etc.

Maybe it’s because I don’t have a project, and the awards in the competition are not as valuable as ACM, so the interviewer didn’t ask me about my resume.

content, and started asking me questions.

 

At that time, my brain was in a twitch, and I only remembered extern C, which was the first question, and the interviewer was at a loss.

1. Global variables

When a global variable is declared externally, the extern keyword is necessary. If the variable has no extern modification and no explicit initialization, it also becomes the definition of the variable, so extern must be added at this time, and the compiler marks the storage space here. When loaded as memory and initialized to 0.

2.extern “C”

extern "C" can not only modify a sentence of C++ code, but also modify a piece of C++ code. Its function is to let the compiler process the modified C++ code in the same way as C language code.

3. The role of the static keyword

During the interview, I only gave a general idea, and I didn't say a lot of details when my head was buzzing.

The role of static when modifying different objects:

local variables:

A local variable is a variable defined in a function. For ordinary local variables, the life cycle ends with the end of the function. Every time the function is re-executed, the local variable has a new value and will not retain the last value. When modified with static, the life cycle of local variables will end when the program ends. When the function is called again, the variable modified with static will retain the last value.

Application: In a function, if we want to retain the last value of some variables, we can use static to modify the variables. For example: if you want to count the number of times the function is executed, you can define an int variable modified by static, and the variable will be ++ every time it is executed.

Summary: A local variable modified with static changes the life cycle, but does not change its scope. The reason for changing its life cycle is that local variables modified by static are stored in the .bss segment or .data segment, while ordinary local variables are stored on the stack.

Global variables:

Global variables are modified with static to change the scope, but not to change the life cycle. Ordinary global variables can be referenced by other .c files. Once modified by static, they can only be referenced by the .c file that defines the global variable, reducing the scope of the global variable.

Function: When a global variable does not want to be referenced by other .c files, it can be modified with static, so that other files cannot be accessed through extern, which is mainly for data security.

Summary: Changing its scope does not change the life cycle.

function:

The function is modified with static, which changes the scope. Ordinary functions can be called by other files through the header file name. After being modified by static, they can only be called in this file, which is for data security.

Function: Some functions do not want to be provided to the outside world, they only need to be called in this file, at this time, they can be modified with static.

Summary: The scope has been changed, but its life cycle has not been changed.

 

​He didn't ask about smart pointers, rvalue references, objects

inherit

Talk about inherited public, proteed, private, multiple inheritance, diamond inheritance

virtual function

From the virtual function to the definition of polymorphism, then to the dynamic and static state of polymorphism, and then to the virtual table.

 

Seven-layer model and five-layer model

I directly dictated the contents of the seven-story model, but I couldn't remember the name of the top floor.

tcp and udp

In fact, what he asked was what the tcp/ip protocol is, and then I happened to read the difference between tcp and udp at noon, so I told the interviewer that I knew this, and then he asked me to answer it, or 4 to 5 Point of content.

The basic difference between TCP and UDP:

1. Connection-based and connectionless

2.TCP requires more system resources, while UDP requires less;

3. UDP program structure is relatively simple

4. Stream mode (TCP) and datagram mode (UDP);

5.TCP guarantees data correctness, UDP may lose packets

6.TCP guarantees the order of data, but UDP does not.

The difference in specific programming:

1. The parameters of socket() are different

2. UDP Server does not need to call listen and accept

3. UDP send and receive data with sendto/recvfrom function

4.TCP: The address information is determined when connect/accept

5.UDP: Address information needs to be specified every time in the sendto/recvfrom function

6.UDP: The shutdown function is invalid

Based on the above differences, UDP and TCP programming steps are also somewhat different

TCP and UDP are protocols in the transport layer in the OSI model. TCP provides a reliable communication transport, while UDP is often used to allow broadcast and detail control to the application communication transport.

 

process

Talk about the difference between a process and a program, PCB, the name of the scheduling algorithm of the process, and context switching.

interprocess communication

It only talks about anonymous pipes, and then lists other communication names such as message queues.

 

​Common Test Methods

Classic black box white box, unit, integration, system

Black Box Testing vs. White Box Testing

Talk about the definition of the two

 

​ There are two cups without scale, one with faucet, one with 5L and one with 6L, how to get 3L

I saw it a long time ago, but forgot, I figured it out during the interview anyway.

Here's what I said:

Fill the 5L cup first, then pour 6L into it, and fill the two cups at the same time, so that there will be 1L in the 5L, then empty the 6L, and pour water at the same time, 6L will have 4L,

Empty 5 again and put water at the same time, there will be 2L in 5L, then empty 6L and put water in at the same time, so that when 5L is full, there will be exactly 3L in 6L.

I thought my answer was very good, but the interviewer said that there is only one tap, so think about it again.

Then my brain was pumped again, and I said to put the 5L cup into the 6L, take out the 5L when the 6L is full, and repeat it three times. After listening to it, the interviewer laughed and said it tactfully (true meaning: your brain is really good) big enough).

I didn't realize until the interview was over, what is the water release at the same time, wouldn't it be OK to change the order of the water discharge? The whole interview is my biggest regret! ! !

 

Sword Finger Offer II 119. The longest continuous sequence

 

The idea at that time was to directly sort() and then traverse the record len and then update max, so I wrote it directly. After all, I haven’t done it before.

Interviewer: What is the time complexity of the current algorithm?

Me: O(N) if sorting is ignored,

Interviewer: How much is that?

Me: O(N*LOG N) + O(N), then take the maximum

Interviewer: Is there an O(N) algorithm?

I thought about it and didn't come out

Interviewer: What are the ways to optimize the time complexity

Me: reduce the number of loops and layers

Interviewer: In fact, there is still room for time

Me: yes yes yes.

Interviewer: Are you thinking about it?

In fact, I thought of hashing, looking for -1 and +1

He asked again: what can reduce the number of comparisons

I was directly fooled.

In the end, the hash did not work out, and the interview was over.

This interview was like pie in the sky, although I may not have grasped it

This interview can be said to be my first formal interview. After an hour and fifteen minutes of interviewing, it is regarded as gaining experience.

So, ironies, you must submit your resume from the sea, in case the pie really falls on you! ! !

You must go through all the offers of Jianzhi, and it is best to know the optimal solution for each question! ! !

It's always good to read more! ! !

After this interview, I found that I have to string together the knowledge points and talk about it again, otherwise my brain will be buzzing during the interview! ! !

During the interview, you can properly guide the interviewer and let him ask you what you want him to ask. Personal test, it is really easy to use! ! !

I hope I can pass (full of hope, although it is not great), and I will be so happy that I can't sleep!

Byte test opened by Didi

Guess you like

Origin blog.csdn.net/Androidyuexia/article/details/132545535