Friday, May 27, 2016

Cracking On-Site Code Interview

It's very VERY important to write code on a paper. You can get better only if you practice hard on this.

When you're coding online, every time you hit backspace, it's gonna hurt in your real interview. This means you'll have to erase and rewrite. Forget reordering of the code, that'll mess up the whole white board.

When practicing on leetcode or anywhere else, try to make sure that the first time you type is your best line of code.

Use short variables, smaller text, and make sure you have complete picture before you start writing the code. Leave extra space to declare additional variables in case needed later.

you should keep in mind all the useful api of them.

Someone advised to split the white board into two parts, one for the code, the other for thinking and drawing. If the whiteboard is not big enough, I think that is impossible to split it into parts

During onsite interviews, try to start writing code as high up as possible so you leave plenty of space below. Leave some vertical spaces between lines so you can easily insert new lines of code if you have to.

Before writing code, it is helpful to break down the problem into several small pieces, ideally each small piece should be a separate function itself. It is helpful if the function itself is trivial to implement but contain some small details which can detract from the main algorithm itself. You can always implement these functions later.

Make sure you have thought of all edge cases and have a clear picture of the entire algorithm before you begin coding. Otherwise you will spend lots of time fixing the mistakes due to missing a specific case / not planning ahead carefully