Remember an interview experience


Interview overview

  1. Position: golang development
  2. Company: * * (the name of the company is hidden, so it is unfair to other partners to go for an interview after reading the questions)
  3. Way: friends push in
  4. Direction: IOT (Internet of things) / blockchain
  5. It took more than 2 hours (half an hour in answering questions)
  6. result:Remember an interview experience Remember an interview experience
    Although it failed, there are still many places worthy of reference. I am optimistic about the direction of the company’s development. I hope it will be helpful to the small partners who want to interview with this company

Interview questions

A total of 10 questions, the answer time is 30 minutes, in fact, these questions are very basic, I put the answers behind the questions

Indefinite multiple choice questions

The specific options are not entirely certain, but these are the contents of the investigation

  1. aboutfunc add(args int {}The correct call options are ()
    A. add(1, 2)
    B. add(1, 3, 7)
    C. add([]int{1, 2})
    D. add([]int{1, 3, 7}…)
  2. For initialization of variables, the following correct usage is ()
    A. var i int = 10
    B. var i = 10
    C. i := 10
    D. i = 10
  3. Reference types in golang include ()
    A. string
    B. map
    C. channel
    D. interface
  4. For initialization of integer slices, the following is correct ()
    A. s := make([]int)
    B. s := make([]int, 0)
    C. s := make([]int, 5, 10)
    D. s := []int{1, 2, 3, 4, 5}
  5. For channel, the following syntax is correct ()
    A. var ch chan int
    B. ch := make(chan int)
    C. <- ch
    D. ch <-
  6. For unbuffered and buffered channels, the following statement is correct ()
    A. Unbuffered channel is the default channel with buffer of 1
    B. Both unbuffered and buffered channels are synchronized
    C. Both unbuffered and buffered channels are asynchronous
    D. Unbuffered channels are synchronous while buffered channels are asynchronous

Answers to multiple choice questions
The following answers are for reference only. The main process didn’t give me the final answer. Some of the above questions were recalled after I searched golang interview questions on the Internet
As long as you prepare well, these questions are all simple and basic

  1. ABD
  2. ABC
  3. BCD
  4. BCD
  5. ABC
  6. D

Answer questions

Whether it is multiple-choice questions or solutions have done similar questions, so brush more interview questions and leetcode no problem
The algorithm problems are all simple and difficult in leetcode, so I don’t think it’s an algorithm problem
In addition to the algorithm, it also examined some basic concepts

  1. Briefly describe the variable escape
  2. Briefly describe what happens when slice appends
  3. Given an integer array nums and a target value target, please find the two integers whose sum is the target value in the array and return their array subscripts.Leetcode link
  4. Given two arrays, write a function to calculate their intersection and difference (the intersection is simple, the emphasis is on the difference set).leetcodeI only talked about intersection, not difference set
    If you input nums1 = [4,9,5], nums2 = [7,5,10,8,4]
    Intersection return [4,5]
    Difference sets return [9], [7,10,8]

I was confused about the problem of variable escape. I didn’t read the definition of this, so I wrote a lot of them

  1. A: I don’t know if I want to test golang’s garbage collection mechanism. Golang’s garbage collection mechanism uses the three color marking method, that is, marking first and then deleting. The specific logic can be explained in detail during the interview (the explanation is a little too long, so the written one will be directly explained to the interviewer during the interview…)

But is this the actual situation?
Not at all!!! There will be an explanation below

  1. A:
    First, see whether the original cap is enough to install the elements that need to be added. If it is enough, add them directly
    If it is not enough, judge the size of the current slice. If it is larger than 1024, it will be expanded by 1.25 times, if it is not enough, it will be expanded by 1.25 times; if it is less than 1024, it will be expanded to twice the original size. Similarly, if it is not enough, it will be expanded by 2 times

Emmmm, I feel that there is no problem in answering this question. After all, I made up for it before the interview
The following is the rule code of the official actual expansion

func grow(s Value, extra int) (Value, int, int) {
    i0 := s.Len()
    i1 := i0 + extra
    if i1 < i0 {
        panic("reflect.Append: slice overflow")
    m := s.Cap()
    if i1 <= m {
        return s.Slice(0, i1), i0, i1
    if m == 0 {
        m = extra
    } else {
        for m < i1 {
            if i0 < 1024 {
                m += m
            } else {
                m += m / 4
    t := MakeSlice(s.Type(), i1, m)
    Copy(t, s)
    return t, i0, i1

The last two questions are both leetcode’s, so I won’t explain them in detail
However, I will tell you how I did it and how to “fool” the interviewer in the following main interview to let him know that I can make a better solution

Finish the problem, I feel I have, I am thinking about 15K? 16K? 18K? 了

Main interview

Because it was pushed in (thanks to @ Liu Shuishui for his recommendation), I directly skipped the previous steps and finished the main process of the question surface (I didn’t seem to skip anything ~~, anyway, I gave the chance)

Explanation of interview questions

The main process first told me the third question of multi topic selection, I chose the reverse Given the concept of reference type, I also made a remark under the third question
Sorry, I’m not familiar with the concept of reference type. According to the meaning of the question, I guess the answer is either a or BCD
But the interviewer was quite satisfiedI think it’s also very important here. Don’t just give up. Always give up your own conclusion and explain why I think soIn the note, I didn’t write why I speculated like this, but in the interview, I explained to the interviewer that Chan can’t be used as a type alone, but can only be chan int, Chan string and so on. Map and interface are the same truth (I’ve thought of this, but I can answer the reverse, I’m also drunk)

The interviewer explained to me the concept of variable escape: variable escape is the change of variable scope
When the interviewer said this, I went over and explained: is it the variable that escaped from the stack to the heap?
After I got the affirmative answer, I went on to say (to show that I still understand, it’s just that I’m not familiar with the professional terms, so I have to take the initiative to say that) the running speed will be affected after stack to heap, because the variables on the heap need to be processed by GC (by the way, I mentioned the tricolor principle in the above answer, which indicates that although my answer is problematic, But it’s not irrelevant ~ ~ hahaha, as smart as I am,I think this is very important, even if the question is not answered correctly, at least let the interviewer know that I know something
Escape analysis of go variablesPlease refer to this blog for details

Algorithm question 1 I used two for loop traversal, before the interviewer’s evaluation, I explained first, a total of half an hour, plus handwritten code, there is no way to consider a better solution, and then talked about using map to solve the better solution (pretending to be perfect)
Actually: the interviewer asked me, why didn’t you think of map at first sight?
Emmmm yes, I was wrong (but at least let the interviewer know that I know a better solution). In fact, I can get double 90 scores on leetcode for twice

Algorithm question 2, intersection, I put the long slice in the map, and then loop the short slice to determine whether the other map contains, if so, append the corresponding item to the result set Limited space on answer sheet plus time limit I gave up the modification)
The difference set also uses the loop of map and slice to find out the result. The main program told me that the better solution here is to use the delete method of map. After deleting the intersection, the rest is the difference set. You can leave your answers in the comment area….
Emmmm is better, but I didn’t expect it
OK, here’s the interview question. Next, I’ve got some go basics

Go basic assessment

I try to recall the questions asked by Cheng at that time. I’m not sure I can finish it
The latter question is a little more difficult than the previous one, but it is not too difficult
The following is just a list to let peers know what problems the examiners are concerned about

  1. Briefly discuss the application scenarios and precautions of defer (close file network request, etc., first in and then out)
  2. Brief discussion on the application scenarios and precautions of Chan
  3. The meaning and difference of process, thread and coprogram
  4. How to ensure the accuracy of data when writing 10W pieces of data into an object
  5. Notes on closures (where the variable reference is a hole)
  6. In fact, what the interviewer wants to ask is whether the interface is the data type of interface {} After the interviewer has corrected my thinking, I will continue to talk about the interface
    … …
    OK, golang’s basic assessment is finished. I feel that I have little problem at present and can basically pass the interview
    Keep thinking about my 15K? 16K? 18K? It’s time to go

Technical assessment related to company business

Emmmm, and then I hung it here
Because their company is doing IOT, they are inclined to the bottom
So I tested some of my operating system principles
As a non – professional born person, I was confused on the spot
I know that the next question I’m going to face is that I can’t answer correctly
However, with a try mentality to continue to Gan
Please do not refer to the following answer, I am random answer, you just need to see the question is enough

  1. How to debug after the CPU and memory on line suddenly increase

    Emmmm, Linux should have a command that can directly check which process caused it, and then .
    Well, I don’t know

  2. What operations cause memory leaks

    There are a lot of IO cases (I don’t know, right? I went to search later, it seems that it will appear without closing)

  3. Which operations will lead to a significant increase in io overhead

    A large number of file read and write operations will lead to a sharp increase in io overhead, so you can use bufio buffer
    Emmm, such as massive read and write of database
    Emmm, such as cache read and write
    (OK, I was wrong) I don’t know
    Network requests can also cause a lot of Io. Strictly speaking, database reading and writing is one of the network requests
    Emmmm (OK, I see. In fact, the word “file” should be removed in the first answer)

… After that, I also asked about some things related to the bottom of the operating system. Because I can’t understand it, I can’t remember how to clear it

Conclusion of the interviewer

Face: you have a good foundation in golang, and there is no problem with the language. However, in the direction of IOT in our company, in addition to the language itself, we also need to understand the principles of the operating system. For example, you don’t think about the time and space of your algorithm. If you go to a position that is biased towards the business, the problem is not big, but our company is inclined to the bottom, so it is not suitable for you
Me: do you have any other departments that prefer business development?
Face: there is another department of the company that is engaged in blockchain, which is more inclined to the bottom

The interviewer is gone and hrbp is here

If our company has other positions suitable for you, we will inform you
(oh, I understand. It means that you are not suitable for our company now. The interview is over.)

Intermediate details that I think are important

  1. It’s best to write the best plan from the beginning
  2. It doesn’t matter if you don’t know something, but if you don’t answer it, you’ll be out of action. Anyway, if you run far away, the interviewer will pull you back. (some people think that understanding means understanding, and not understanding is not understanding. Don’t talk nonsense in front of the interviewer. The interviewer can see it. In fact, I don’t think so. Even if you say something wrong, you can at least let the interviewer see me in it He knows a little about which aspect)
  3. It’s impolite to interrupt the interviewer, but you shouldDiscretionConsider appropriate “interrupting” the interviewer’s speech in a key place, and then you can say it later to let the interviewer know that you know this knowledge point (this place must be well controlled. If you are not sure about it, no matter how good your answer is, you will not have it)
  4. Make clear the “attributes” of the company you are interviewing for, and review them accordingly (as long as I have read the principles of the operating system in advance, I will not hang up so without suspense)
  5. If you have a good open source project (or open source project you are involved in), be sure to write it in your resume, if notMy resumeThere are things related to open source. I may not even have the opportunity to interview. If you have a suitable job, you are welcome to recommend it,My resumeThere’s a copy on GitHub

Be reasonable
I have been very satisfied with my performance in the interview
Although I failed, I told you all I knew (of course, grpc and http2 didn’t take the exam)
And through the interviewer’s evaluation of me and the situation of answering questions, I have more confidence in my basic operation of go language
Then, a person, a book, and a month give you a miracle (operating system principles from introduction to abandonment)
Me a year ago: PHP is the best language in the worldRemember an interview experience
Now I: go is the best language in the worldRemember an interview experience

I wish myself a successful transition to go developers this year

Last, last
Red fire

This work adoptsCC agreementThe author and the link to this article must be indicated in the reprint

Recommended Today

Detailed steps for installing Perl and Komodo IDE for windows

Perl official website: document: address: The installation package of Perl Windows version is divided into activestate Perl and strawberry Perl. For the difference between the two, see: Note: the download speed of activestate Perl is slow. You may need KX to surf the Internet I have uploaded all the versions of […]