We all dislike them, and there is always this debate going on about whether they are really useful or not for getting the right candidates. But it's undeniable that today, if you want to land a kickass job, you have to master the art of the Code Interview. I had to do a lot of them in the past... some went well (got a job and all that) and some didn't (though I learned useful stuff from them). And since I became unemployed after the Yahoo gig, I entered a very big interviewing spree that I'm very glad I survived.
So I'm going to share the things that helped me survive this time.
I bought some time ago the classic Cracking the Coding Interview by Gayle Laakmann McDowell. It's pretty good for starting to get a hang for it, and the chapters non-specific to coding questions (preparing the culture fit interviews and all that) are pretty spot on with what you end up being asked in Google, Yahoo, Facebook, Twitter, etc.
I also got Data Structures and Algorithms in Java by Robert Lafore. It was great for understanding in depth some of the quirks of the data structures you desperately need to know for the interviews - and you will probably get asked about them. I am really grateful for the chapters on Hashtables, Graphs and Heaps, for example.
I would always set up a corner of the house for studying, apart from where I have my main computer.
I try to keep the distractions to a minimum, so the phone is silenced. The problem solving phase is key, so the less you put hurdles to yourself, the better.
- LeetCode. In here you can find a ton of problems of varying difficulties, you can answer them there and get them checked with a ton of possible inputs. The easy ones are confidence builders, the medium/hard ones are somewhat tough and a good taste of what you are going to find in some hard on-site interviews. Usually you will be asked things around the medium level spectrum, but I've been asked some of the hard ones. A hiring manager from Google recommended this site to me, and I can assure you it's pretty spot on.
- CareerCup. This one contains a ton of interview questions, though you will find some fake ones from people trying to make you do their homework. But don't worry, they are pretty recognizable. This site is ideal when you are preparing a specific interview for a known company, and it will help you find patterns of question types based on the number of times a question is repeated by a company. Also, this gives you a taste of how the questions you might get asked are which is always nice.
Preparing for an interview
The most recommended thing, at least at first, is solving the problems in paper. And it is recommended for a reason. Do it!
After you have done that quite a bit and you get the glimpse of how your life would be without a proper IDE, you can start using the computer. I used Sublime Text and Atom in the past for this, because they don't offer the same level of help as other IDEs and you are in complete control. I also store all my solutions in a Dropbox directory so I can get back at it later. This has helped me a lot whenever I wanted to check how I did something in the past.
Usually you end up chatting with someone in Skype and opening some Google Docs or CollabEdit. You talk with the interviewer for about 10 min about your experience and some basic questions related to your desired position (ie Android in my case). I've been asked about the android lifecycle, how the garbage collection works, and even chatted about what was presented in Google I/O.
And then they give you a problem to solve. Usually it's not too hard so don't be too afraid. I've been asked things like implementing specific "weird" iterators, playing around with binary search trees, bitwise manipulation questions...
You pass the phone screen phase, you arrange the on site interview, and you dread this moment because you know it's coming... The whiteboard.
About the whiteboard situation, well... my only advice would be to try not to be too nervous. You are going to be nervous, sure, and it probably can't be helped. But try to manage it and use it to your advantage - a bit can help you to focus and be extra aware.
So, to survive, you basically have to solve a ton of questions by yourself, compare the answers with the good ones (watch out for the best big-O solution) and study data structures.
For me, this time LeetCode was a really good companion. So give it a spin! I did about 50 problems from there and around 40 from CareerCup, and it was very helpful.
And remember, even if you fuck up (I also did), it's always helpful and it serves as cautionary tale for your future self!
There is a ton of advice in the coding interview books and articles all over the internet. You won't be short of people telling you what to do in these situations.