r/programming • • Sep 22 '20

Google engineer breaks down the problems he uses when doing technical interviews. Lots of advice on algorithms and programming.

https://alexgolec.dev/google-interview-questions-deconstructed-the-knights-dialer/
6.4k Upvotes

1.1k comments sorted by

View all comments

Show parent comments

100

u/aoeudhtns Sep 22 '20

The way I also look at it: since we haven't found a predictive method, use the cheapest non-predictive method that gives you a minimum level of confidence. In other words, I use the traditional "tell me about your work experience" style and expand on things as we go, delving into rationale for technical decisions that they made and what they found easy vs challenging. Maybe throw a hypothetical based on something real from the team they're interviewing for and try to gauge their critical thinking ability. Etc.

In the absence of any work experience, then I quiz on retention from CS curriculum and try to gauge interest in the field. There's no career motivation like self motivation.

And of course, the candidate has to want to work for us, over somewhere else. I personally would bail out of these puzzle question interviews that have no bearing on the actual job.

99

u/[deleted] Sep 22 '20

One thing that I have started to do is to take a utility function from our codebase (something like a string parsing routine), obfuscate the variable names, then hand it to a candidate and ask what it does. This, IMHO, does a better job of testing what developers actually do (dig through code to add features or fix bugs) as opposed to what we like to think we do (use our brilliance to create the most fantastic software the world has ever seen).

44

u/aoeudhtns Sep 22 '20 edited Sep 22 '20

That is a great idea. And reading code is harder than writing it anyway. Plus I think interviewees would feel less on the spot, even though the task might be more difficult in reality.

Edit: I'm totally stealing this next time I do interviews.

11

u/Phailjure Sep 22 '20

feel less on the spot, even though the task might be more difficult in reality.

I think that's extremely true. If you gave me a programming puzzle with no time limit vs digging through some poorly commented code, I'd feel less stress with the puzzle. If you ask me to do it in 30 mins, no google, while I watch you, I'd rather have the code, because I cannot think creatively to solve the puzzle in that scenario. Reading the code has obvious places to start and things to do, implementing a solution while staring at a blank whiteboard just leaves me standing there wondering where to start (I somehow managed and got a job, but it felt terrible).

Focusing the interview on talking to people about their experience also helps a lot, and is easier for the interviewee. That and asking questions about the usual things they would run into in that position (and some exception cases that may have come up). We did that with our last few hires, it was really easy to catch the one bullshitter, and the guys we hired seemed knowledgeable, and turned out to be good at their jobs.

2

u/StorKirken Sep 26 '20

How has the response from candidates been?

→ More replies (1)
→ More replies (4)

6

u/hparadiz Sep 22 '20

I love this.

3

u/Skytale1i Sep 22 '20

This is such a good idea!

→ More replies (2)

40

u/dnew Sep 22 '20

I've found fizz-buzz level questions absolutely essential if you expect the candidate to program. I'll start with the discussion like you say, then try to come up with either a simple programming task ("print all the primes less than 100") or some straightforward questions their experience should be able to answer (like "what's the difference between an inner and outer join" if they claim they have DBA experience). Otherwise, I tend to get BSed into believing the resume.

The real problem IME at Google is that the job you're doing has very little to do with these sorts of algorithms and much more to do with things like "how do you write a 2-million-line program that you can modify at random for five to ten years while never actually taking the server offline". That isn't something that this sort of algorithm question will handle.

28

u/fishling Sep 22 '20

It kind of of sounds like you try to come up with a coding issue on the fly rather than being consistent for each interviewee. It's not clear since your second example isn't a programming task and asking questions based on experience should be done for all candidates.

try to come up with either a simple programming task ("print all the primes less than 100")

I think this is a clear example of a very bad interview question! It is pretty easy to come up with an inefficient algorithm (test modulo division of each potential dividend for each number) based on the definition of prime, but there are clever algorithms (like Sieve of Eratosthenes) that do a much better job that the candidate may not be aware of. Expecting them to come up with that from scratch or even to recall it from memory, especially in an interview environment, is very unreasonable in my view. Plus, I imagine a candidate would be under extra stress knowing that there is likely some clever solution for primes that they don't know about. So this really isn't a programming test at all, it is a "cleverness" test of the worst kind.

19

u/coffeesippingbastard Sep 22 '20

I think this is a clear example of a very bad interview question! It is pretty easy to come up with an inefficient algorithm (test modulo division of each potential dividend for each number) based on the definition of prime, but there are clever algorithms (like Sieve of Eratosthenes) that do a much better job that the candidate may not be aware of. Expecting them to come up with that from scratch or even to recall it from memory, especially in an interview environment, is very unreasonable in my view. Plus

So this depends on the interviewer but based on OP's comment- I don't think they are looking for a Sieve of Eratosthenes. Just something that works- ANYTHING.

Moreover, it is incumbent on the interviewer to set guidelines and coach the candidate to the right path. It is always good to start with some sort of implementation- efficiency be damned- just get it working first.

16

u/fishling Sep 22 '20

Even if all they are looking for is something that works, that is still not a great question, because the naive implementation is just some boring lines of procedural code AND it still puts the expectation/stress on the interviewee that there is a potential trick they are missing, despite what the interviewer might say. There aren't any edge cases to discuss either.

Something like "find the second biggest number in a list". There are a lot of different approaches that seem equally valid (sort, find biggest then find again ignoring biggest, iterate once and track biggest and second biggest, etc), no sense that there is a mathematical trick that you haven't memorized, and some interesting edges cases with small lists, single-valued lists, repeated numbers, etc for clarification, testing, error handling, etc. No matter the approach, you'll end up with more interesting code than a naive prime implementation.

17

u/dnew Sep 22 '20

because the naive implementation is just some boring lines of procedural code

And what do you think fizz-buzz is? It wouldn't be a meme if it wasn't necessary. I've interviewed people with a decade of programming experience that couldn't nest an if statement inside a for loop.

your second example isn't a programming task

Correct. It's just something to see whether they were a dead weight in a group that was actually doing what their resume says, or whether they actually did something along those lines. Hiring really went downhill when candidates started suing their references for being honest.

you'll end up with more interesting code than a naive prime implementation

That's actually an excellent (and better) question. Were I still in the interviewing realm, I'd definitely switch over.

6

u/StabbyPants Sep 22 '20

hell, i've got a senior developer on my team who decided that it'd be a good idea to make a business logic decision based on what the trace id prefix was

→ More replies (1)
→ More replies (12)

5

u/gropingforelmo Sep 22 '20

If I'm trying to hire a junior or associate, I'll toss one of those simple algorithm type questions at them first thing, just to weed out the people who can't code their way out of a paper bag, and somehow got to the technical interview.

If they can't solve Fizz Buzz in a reasonable time, they're going to be a drain on the team rather than an asset.

3

u/fishling Sep 23 '20

Oh for sure, I hope I didn't come across as being against coding in an interview. I definitely think being asked to demonstrate skill can be a reasonable ask, if done correctly with the right question and setup. I try my best to accommodate interview anxiety both in choice of problem and how I try to make them feel at ease.

It's kind of odd: When I give a choice of paper, whiteboard, text editor, or IDE/REPL, I am surprised how few people actually choose a computer option. Maybe they are worried that I'll want to run their code. :-)

Ideally, I would like to do a bit more, but I think take home work or on-site work is really disrespectful of the interviewee's time, and can be an uneven playing field based on many real-life reasons that I am not allowed to ask about and therefore cannot know.

→ More replies (3)

10

u/aoeudhtns Sep 22 '20 edited Sep 22 '20

Yeah, I should have mentioned, we usually do a very short programming quiz like FizzBuzz. Something simple like that is usually enough to filter out the BSers. But the point isn't the puzzle to solve, it's really just the basics of: can you string a short, simple implementation together? This still doesn't eliminate the people who memorize all this crap. Although the memorizers are probably capable of being productive anyway. I have a guy on my team who struggles to create things from scratch, but if he can find a blog or article that sets up a skeleton, or a stack overflow post that provides a partial solution, he's good to go.

Sometimes I ask the younger ones about their experiences in classes. When I was in uni, I noted there were two groups: those who struggled with syntax, and those who struggled with the actual problem. Of course the syntax-strugglers had a hard time even getting to the problem part. So if you can get someone to divulge that declaring variables, figuring out where to put punctuation, and stuff like that was a challenge for them - then you have a good data point for considering elimination there as well.

Edit: sorry for all the edits here.

21

u/Miserygut Sep 22 '20 edited Sep 22 '20

I have a guy on my team who struggles to create things from scratch, but if he can find a blog or article that sets up a skeleton, or a stack overflow post that provides a partial solution, he's good to go.

I have that problem. Mainly it comes from never having had a consistent problem domain to work in. It's always been "Hey, this random thing is broken, learn just enough to fix it then move on to the next random thing". Sometimes that 'just enough' is deep in the guts of totally unrelated components but it's all just layers of complexity on top of one another in the end. This means I'm very good at fixing problems and picking up new things, but it also means I don't ever really get to start from scratch on problems - ever. As a result I'm slow at starting from scratch and it feels like reinventing the wheel. I might as well just copy from someone whose main role it is, tweak it to do what's needed and move on to the next random broken thing.

5

u/ambientocclusion Sep 22 '20

You have a valuable skill. I hope your team and company recognize and reward you.

4

u/Miserygut Sep 22 '20

I think they do, I'm not sure I do. :D

6

u/aoeudhtns Sep 22 '20

Yeah, please don't read too much negative into what I was saying. "That guy" is one of the more effective engineers on his team. We just have to note that if the problem he's working on hasn't been at least partially solved before, or is some rather unique or novel combination of things, he'll need help getting off the ground. It's really not a problem so long as you have someone who can start with a blank page somewhere on the team.

7

u/Miserygut Sep 22 '20

Asking for help is critical to being effective, and not feeling embarrassed when asking about something trivial or obvious to others because it's what they do day-in-day-out. Ultimately all these methods and approaches are just tools for solving problems at different levels. I'm more than happy being a generalist even if it's a much harder sell than being a drop-in replacement developer who is familiar with a relatively narrow set of tooling. I expect anyone with experience would say the same.

4

u/aoeudhtns Sep 22 '20

100% agree with you.

In fact for the freshly-graduated hires, or interns, we tell them explicitly to ask for help. It's easy to explain that it's better to ask a potentially dumb question than to fail to meet your goal because you were stuck and never got help.

Although I usually tell them in a joking way that if the 1st or 2nd Google result solves their question, that's not a good look. But still better than being 2 or 3 days late and the 1st Google result solves the question.

→ More replies (1)

3

u/nutrecht Sep 23 '20

I use the traditional "tell me about your work experience" style and expand on things as we go, delving into rationale for technical decisions that they made and what they found easy vs challenging.

Unfortunately we humans have huge psychological biases regarding interviewing. We are in no way objective and you decide whether you want to hire someone within the first few minutes. The rest of mostly looking for confirmation to that decision.

Unless you did extensive training on the matter (which most companies don't offer) you're guaranteed to be bad at it.

This is why a pair programming coding test on top of an interview is IMHO a must: I've seen a lot of really bad developers who do really well in interviews. After all; they get to practice the process a lot more than the typical developers interviewing them.

2

u/badtux99 Sep 22 '20

Pretty much my approach to interviewing as an interviewer. If I have questions about whether they've actually done the things they say they've done, I might have them whiteboard pseudocode for something they said they did, then ask questions about it. So far the process has worked well for us, we haven't hired any dud engineers anyhow, they've all worked out quite well.

→ More replies (2)