I have been interviewing companies recently. Here I summarize what I learned from my experience. Interview is just a show in which you perform to the best of your ability. If the interviewer like your show, you win; otherwise, you lose. There is a chance that you play better than what you are, this is GOOD and this is what we want.

Understand What Companies Want

First of all, know what companies really want.

Use a Pattern to Solve Problem

1. Exemplify: Use an example and visualize the problem.
2. Simplify: Simply the question and make it simple enough to solve, and then solve the complicated.
3. Reflection: Think and solve the problem by using the methods you know, e.g., binary search, various kinds of sorting, handle array from both ends, etc.
4. Brain storm all possible data structures: array, linked list, stack, queue, hash table, heap, etc.

Keep Conversation Going

You may find it is hard to keep the conversation going. One way is to start with a simple naive solution.

For example, given an array of integers, all elements are in pairs except for one, how to find the single number?

Naively, a hashmap can be used to solve the problem. Then we think more advanced approach.

Practice