Thursday, March 22, 2007

Howto Pass a Silicon Valley Software Engineering Interview

I do a fair bit of interviewing. This probably averages about 2 to 3 interviews per week - mostly for Java developers. I'm also giving a birds-of-a-feather at the Software Developer's conference tonite in the Santa Clara Hyatt bar on just this topic (7:30pm if you're interested).

Now mind you, being an experienced interviewER does not necessarily give you relevant information on being an experienced interviewEE. However, the latter is hard to gain a lot of experience at. Because of course, if you're good at it, you tend to not do it for very long (i.e., you get hired).

Before Google, I interviewed at several startups in the valley. And combining that experience plus what I know about how I interview at Google and how I interviewed at Preemptive I do have a few guidelines.

1) Don't interview at your dream job first.

If you haven't interviewed in awhile, your first interview is likely not going to be great. It's not because you're not a crackshot developer or a math whiz. It's just because you aren't familiar with the whole process. From getting used to jumping from topic to topic all the way to saying why you want the job. Its always a good idea to interview at your 3rd or 4th choice first.

2) Be positive - no swearing.

You will get asked about your last job. Saying your manager sucked and the dev team was a mess wins you nothing. I've seen candidates attempt to put down some technical faction or previous employers seeking my solidarity with them. Nuh uh. Doesn't happen.

Why are you leaving your current job? Simple - because this new job is a better opportunity. Your last job was a fine career builder but this one's business model or development principles or philosophy or job description or reputation suits you way better. Not to mention your skillset can bring significantly more value in this new position.

Don't tell your new employee what's wrong with their products - mention you hope you can (non-specifically) improve such products. Even if asked what you'd improve, phrase it such that it is indeed an improvement and not a fix for something you think is terrible.

Also - forget technical religion. If you love Agile say so - but don't pretend its the only solution. Millions of people get work done on windows, linux, agile, waterfall, C++, java, .NET everyday. All are solutions - sure, some are better than others and defensible positions are great - but unfounded zealousness is not.

And, I am amazed I need to write this - don't swear. Its a respect issue. You don't know your interviewer. Some people don't mind swearing - some do. There's really no need.

3) Check your attitude at the door.

As I've said in previous articles, if you are the smartest person at where you work - QUIT. Similarly, its a silly idea to join a company where you will be the smartest person the day you start. Therefore, if you ARE smart, you will be looking to join a company where you AREN'T the smartest person. Therefore - you should leave your arrogance about how great you are outside.

I ask most every candidate to rate their Java and C++ skills on a scale of 1-10. Then I write that down for the next interviewer. At Google, you never know who your interviewers are going to be. If you say you're a Java or C++ expert that rates a 10 - you darn well better be - because you never know - your next interviewer could be Josh Bloch, Matt Austern,
Guido van Rossum,
or Ken Thompson. Or worse, someone else you've never heard of that's a super crackshot - and there are plenty of those.

Again, I'm amazed at people that give their interviewer attitude. It's such an obviously stupid act that I have to question the person's intelligence in addition to being annoyed by their arrogance.

4) Be passionate about development.

I have a dirty secret - if Google stopped paying me tomorrow, I'd still come to work (unless they like took my badge too and got Hector the security guard to watch out for me - that dude could smoke me). God forbid that while sleeping I have a dream that solves a coding problem I've had the day before. When this has happened in the past, I found myself sitting awake in bed with my mind racing. I was too excited to sleep and figured I might as well drive into work and start implementing the solution (despite the fact that it happened to be 4am).

The number one thing I look at on resumes (and I don't look at resumes all that much) is extra-cirricular coding activities. I want to hire engineers that I want work with. And those engineers are passionate about cool algorithms, slick code, and new ideas. They do that stuff in their spare time - its not just a job, its what they do because they love it.

5) APIs really don't impress.

People seem so proud they know a lot of APIs. As far as I know, APIs were designed to be easy to learn. I'd really rather hire a smart person that I know can learn most any API than one that brags about the few they already know.

I'm not saying knowing APIs is bad - it's not. It's just not the most interesting thing on your resume.

6) Know algorithms and data structures.

One theme in Silicon Valley is massive amounts of data. And its not always of the classic relational database type of data. Its massively huge datasets that require plenty of processing (imagine the graphs made for page rank).

One of my favorite/fun interview questions (actually, probably one of my ex-favorites given that posting it here means its too well-known) is simply how to sort some objects. The absolute beauty of this question is that very many software engineer interviewees have given me a suboptimal answer for this - whereas my mom (who, despite making crazy good pirogis, has zero computer training) got it right.

Here it is, as I ask it of engineers, and as I asked it of my mom:

Engineer's version: Say you had a million objects in memory (assume we have no memory constraints) all of type UniversityStudent. These objects have two fields:

String name;
int numberOfYearsOld;

What is the fastest way to sort these objects by "numberOfYearsOld"?

... So.. whats the answer? quicksort? mergesort? whats the running time?
The most common answer I get is something like quicksort with an average running time of O(nlogn). For a million objects, that's something like 20million operations (comparisons) to do the sort.

Mom's version: Say you came into a very large room with a million papers in a stack. On each paper is written the name and number-of-years-old of a given student. Whats the fastest way to sort these papers by hand by number-of-years-old?

Mom made stacks. A stack of 18yr olds. A stack of 19yr olds, etc. She needed a possible of about 100 stacks maybe (ages 10-110). How many times do you need to look at each paper? Once. Right. That's 1 million operations or O(n). Go mom.

Of course, Mom got it right because she had no preconceived notions about the problem or sorting in general. A candidate that memorized sorting algorithms before coming to the interview probably robotically responded with O(nlogn) without really thinking about the problem.

If you've written plenty of code, you should be familiar with when to use what data structures and to know their runtime characteristics. You should know that a hashtable's worst case search time is linear - and you should have an idea how to avoid it. And why you might use a binary tree instead of a hashtable even though it's an O(logn) lookup. And that O(1) is effectively the same as O(100). Surely the subtleties are situation dependent - but that's why you understand it - to apply it in the right situation.

This is all datastruct and algorithms 101. I perpetually hear developers tell me that they learned that stuff in school but now forgot it. Personally, I wonder what the hell they have been coding? If you've just been gluing APIs together then thats nice, but its not very interesting. Even if you don't interact with them directly, knowing data structures and algorithms is key to understanding performance. This is not premature optimization - this is choosing the right tool for the job. And that choice is often wonderfully subtle.

And if you decide to do 20million operations when you could very easily instead do 1million, eventually we're going to have some problems.

7) Be an engineer that your interviewer would want to work with.

I don't know exactly what that means because it will vary with every interview and interviewer. Obviously be genuine but be passionate.

8) Know the language you say you do.

I try to phrase all language questions as things that I think any developer that has worked in a language for a year couldn't possibly not know. Tell me about wait, notify, and notifyAll (3 methods every Java class ever created has).

I'm not worried if you don't know Java generics, but if you say you do, I'll ask for some code.

Good interviewing coding questions in my opinion should be meaty, do something, and take no more than a whiteboard.


There really is a spectrum of good to poor engineers. And the one theme that runs through it all is passion. Not for a given language or system - but for problem solving. And building things. Certainly a good degree doesn't hurt but I promise you its not the whole story. I have flunked MIT Ph.Ds. and recommended-for-hire people with very modest formal educations.

As I've said before - the interview is very very honest. Its about you, the whiteboard, and what you can do.

Bottom line is I want smart, passionate, crackshot developers. They're out there and I want them here - partially because they'll help to make my company better. But also because they're very likely going to be smarter than me - and working with them is going to make me better.

Notes from my BOF can be found HERE