Gayle Laakmann McDowell’s session, “Cracking the Coding Interview,” was likely the most popular event at the 2012 Silicon Valley Code Camp conference. McDowell knows her subject well. She’s the author of a Cracking the Coding Interview, as well as The Google Resume and is founder of CareerCup, a website that hosts more than 8,000 interview questions for software engineers.
Here are a few highlights from her seminar:
Be prepared to write long hand
McDowell’s first piece of advice for a coding interview is be ready to write out your code by hand. You won’t have a compiler in front of you, so practice writing and debugging on paper. Make sure you get all your semicolons in place as pseudo-code won’t fly.
Keep a few tricks up your sleeve
McDowell recommends these mental tricks to help you work through questions you can’t answer off the bat.
Pattern matching: Think about what interview questions are similar to the one you can’t solve. Approach the solution to the problem with the version you do know.
Simplify and generalize: If the problem is too complex for you to wrap your head around, simplify it or tweak some of the constraints so you can solve an easier version and then generalize a solution that reflects the more difficult problem.
Base case and build: Solve the problem for the n=0 and n=1 case and see if you can use solutions from prior problems to solve for n=2 and n=3, and then build from there.
Stay calm and carry on
McDowell says that one of the grand misconceptions of the coding interview, is the belief that a developer can hear a problem and then just belt out the right answer. That’s not how it works. The interviewer really wants to know how you think about what’s been presented and how you are going to approach it. She advises calm. Don’t expect to know the right answer immediately. It can take the best candidates 30 minutes or longer to work an issue through.