The other day I read the wonderful text
“I saw a hack in the face” about the whiteboard interview (this is when a candidate is given a board or a piece of paper is put and they say: “write this program on the board”). The article is essentially correct, only a little bit in the style of a crying princess for lost youth, well, well, the main fools, of course, are the candidates. But I’ll reveal a secret: those who hire are often fools too, because the candidates themselves sooner or later find themselves in the position of hiring, and the foolishness does not go anywhere.
In fact, stupidity, most candidates are illusory and it comes from the fact that they do not really understand the rules of the game, and on the other hand they do not always play honestly. We will understand how it is in life, and how to deal with it.

')
Who is in front of you?
Let's start with the fact that the interviewer, in fact, is not necessarily worth the goal to hire. Sometimes he needs exactly the opposite, no matter how strange it sounds. It could be some kind of internal political game, or a desire to assert itself: let's be honest, we, programmers, - after all, they are still snobs and zaznayki.
Even if they want to take you, there may be an obstinate ram in front of you who even often conducts interviews, and may even do this for three or five years, but during that time he didn’t spend a single minute trying to figure out why Why does he ask these questions? And here attention! Why does he count only certain variants of answers: not a step to the side and even up (in the style: you complicate too much, I did not ask you about that, and so on).
What are they talking to you about?
Until I started conducting technical interviews myself, it seemed to me that on the opposite side of the table there were not gods, but people. In reality, in a large percentage of cases, the interviewer understands the question worse than you - and this, by the way, is completely normal. In the company they keep him by a combination of different factors, and his goal is to measure you, and not to measure yourself with knowledge or something else.
Those. when coming to the interview, remember that if a person is interested in hiring you, he will not consciously throw you down, he will find out the opposite (using a scientific method) the depth and width of your knowledge. This person may not know something, not understand something, and even make mistakes - this is also normal. It is important how much you can explain to each other: he is the goals and objectives, you are your abilities and wishes.
This is a very important consideration. A good interviewer is trying to understand how you solve the problem. And he knows the right decision without you. Or he doesn’t know at all, but then the path that you have taken before the decision is all the more important for him.
What is expected of you?
Here again about the sheep. There are people who expect the right answers from you. Well, what can you do? Tell a story from the life of St. Petersburg State University.
At the Physics Faculty of St. Petersburg State University, the most difficult subject was ... the military department. Nothing could be understood there, but it was possible to just memorize: it was impossible to change the notation of variables, all formulas were presented in the most complex form (and they could not be simplified), integrals had to be forgotten, about a brilliant course in radio physics, which you just read - all the more. In a word, trouble, especially for those who really understood physics.
If you get to a person who wants to hear the right answer from you, then you can’t do anything about it. Fighting and pushing down with intellect is useless. But on the other hand, from such an interview, one can extract indirect information about what is happening inside the company. Nothing good: drought and gloom.
I somehow was in this situation myself. I was constantly poked with Microsoft, although we talked about completely abstract things. Then it turned out that Microsoft has some kind of text, or a directive: “To all people with an brainplate advance, walk and think along this line.”
By the way, this is the most disappointing and the biggest mistake that
deters strong candidates : if a person does not know something, but offers to withdraw, think up, talk about it - this is a find, but often the interviewer says “stop, I'm not interested”, and puts himself in a piece of paper minus. And the candidate at this moment is boring and dull, because he understands that his company’s ability to solve problems is not needed. And, believe me, this is just not a feeling, most likely within the company there really is no need to solve complex technical problems.

Technology
But still, what should a candidate do during the white board interview in order to pass it as well as possible? Here I proceed from the assumption that you have come to a sane interviewer who does not want to overwhelm you (but this does not mean that he will save you).
- Always speak. Talk about what you think, what ideas you have. Explain your train of thought. No one person can immediately give the correct answer, and your train of thought - in fact, is the most revealing in you.
- To err is normal. Calmly say: “now I see that I was wrong” or “my decision was not perfect, let's see how it can be improved” or “yes, I suggested a bad option, let's suggest another”.
Why : If you were given a task that requires insight ( that is, the worst possible of all possible tasks ), then, of course, no reasoning will help you. In all other cases, the interviewer is interested in exactly how you go to the decision.
- Start simple. Do not complicate the decision until you are asked. Remember how you program. Almost never you write the entire solution, you come to it gradually: first one aspect, then another, then the third (and sometimes you even stop, because premature optimization is evil)
- Do not guess. Interviewers rarely want to confuse you. If you do not know where to go, then just ask: with great probability they are waiting for this question. This question shows that you understand the area in breadth. And with a high probability, the answer (data assumption) will make your decision easier and more transparent.
- Forgot method name? No problem. Nobody requires you to remember the names of the methods and their correct spelling. It is enough that you know that such functionality is easily obtained from somewhere. To demand knowledge of the order of parameters on the interview (nowadays, when even in MS Word there is a company) - wildness.
- Do not be afraid. If it seems to you that they are trying to catch you on something, then it’s very likely that your head is too complex or foggy, and they are waiting for a simple and intelligible answer. Answer simply by describing the limits of applicability. If they want to hear more from you, they will ask you (or not, because they will see that you already know what is there, beyond these boundaries).
- Forget about specific languages and frameworks. Most often, you are required to understand how things are done inside. If you are asked how the HTTP protocol works, then you do not need to tell how to make an http call from Java / # / Python or your favorite language. Tell us what is DNS, TCP, keep-alive, headers and the body of the request (and why HTTP / 2.0 is a pain).
If you’ve been flooded with an interview, then my advice is: write a biting letter to these idiots that you are doing really complicated things, and since they tried to force you to write an algorithm on the board, they are looking for an encoder, and not such a serious person as you. After that, relax and go read another muddy book about how to write xml-configs.
And all my text, of course, does not negate the fact that you know everything about meat and bones: data structures and algorithms. But about it is very easy to find on the Internet at the request of hacking code interview. Otherwise, of course, my first point (“Always say”) will only make you worse. Always learn!