294 points · by gameguy43 · 13y ago · 151 comments
Not to mention that this is not exactly an obscure trick. If you've seen it a few times it is trivial to remember the trick and apply it. It's been awhile since I've looked at the 'interview questions exposed' type books or websites, so it didn't leap immediately to mind. Would you really select against me because I haven't read such things?
edit: my phrasing was way to strong and unfriendly. I reworded the first sentence.
For example, a naive approach is to sort and find the element where arr[n] == arr[n+1]. From here, the interviewer can see if the candidate is aware that most sorts are O(nlogn). A better candidate knows that with a fixed range, you can sort in O(n). Maybe the candidate will go with a hash table or set and check for the duplicate that way. I've interviewed people who look good on paper but don't intuitively grasp how to use hash tables, so this is a useful screening exercise.
My point is not that this question isn't simple, it's just that there are a number of ways to approach it besides the "aha" moment that give you insight into how a candidate works.
For example, let's say I need to hire somebody to do a lot of low level optimizations. I can ask them some specific problem, and keep saying 'make it faster'. Or, I could start talking to them about cache misses, and see if we can just talk about it. Anyone that can actually do the work will be bringing up the pipelines, out of order instruction executions, the costs of going off chip, how to organize data and programs to minimize cache misses, well, the whole ball of wax. In that context I can start feeling out if they are original thinkers, or just plodding followers of some rules they read on HN or somewhere. If they don't have experience in this, but I think they might be good at it, I can talk about their debugging skills, or some other engineering/optimization problem that they have solved. I'll admit that this all presupposes an existing career - I do find it harder to interview and evaluate recent grads because it is all speculation at that point. Heck, if all you have done is CRUD apps I can see if you have thought about the good/clean code vs put it together to get it out the door to get market share issues. There is no one, clear, obvious answer, and a good mind will see that, and be able to free associate about it. A mediocre mind will repeat whatever HN quote resonated with them when they read it. If you can think about that clearly, you can learn the micro-architecture and then use the same style of thinking to optimize code.
So, all of that is why I don't like 'aha' questions, or even reverse the string questions. I don't think it has any predictive value. Certainly, Google, which asks tough algorithmic questions, admits that with all their collected data they see no correlation between interviews and performance, except for the situational type interview stuff I write about (and that the OP wrote about).
This is what it's supposed to feel like when Interview Cake offers the "gotcha" that we can solve the problem with O(1) additional memory after you say you have an answer, before showing you the final solution. In real life I wouldn't fault the candidate for needing the nudge.
Another flow I've considered is to make the question multi-part, with the second part (the "follow-up" question) adding the O(1) time constraint. I'm worried that with this flow, in the case where you do jump right to the summation approach, the app will feel naive because it will pose a whole new question that you've already answered.
So far I think the best approach is to keep the current flow but use a less harsh word than "gotcha." What do you think? Do you still think the question is just fundamentally too much of an "aha"?
(I agree that if the candidate jumped right to the summation answer on this one it's a weak signal. I wouldn't ask this question in an interview--it's not my favorite either, and it's unfortunate that it's a common one. My favorites aren't on the site yet because they're hard to explain without pictures. Adding those pictures is the next project!)
Soft skills, on the other hand... is this person an asshole? Inflexible and dogmatic? Timid? Boring? That stuff drags down a whole team.
The previous 3 I get, but these two? Maybe we should be interviewing for the ability to get work done without being affected by other people?
Boring people? Hell, I just don't want to work with them. If I have a say in hiring someone I'm going to spend hours a day around, I'm going to do my best to make sure it's someone I find entertaining.
What the fuck, man? Are you trying to hire professionals to do a job or are you treating hiring as some sort of fucked up way of making friends?
But, at the end of the day, teams can hire who they want, so I definitely don't think this sort of thing is inherently wrong -- I guess I miss the part of the industry where one could work in near-solitude since that's what I prefer.
<!--
<li>
<a href="/all-questions">All Questions</a>
</li>
-->
Note that they've commented out the link for some reason.TL;DR; Don't waste your applicants time or your own
## The Interview Interviewing should have two parts, imo:
* Confirming that I actually wrote the code I sent you and know what it means
* Confirming that you want to sit next to me for the next six months
I can tell you right now that if I take time off my current job to go sit in your office for an interview and you ask me basic questions like "What is MVC?" or "What's the difference between a POST and a GET request?", I'm going to thank you for your time and walk right out.
Why? Because my Github profile, which is featured prominently on my resume, contains examples of both. Half my projects are MVC projects, and many of them use 3rd party APIs (or are even APIs themselves!). The fact that you're asking me basic definitions means you didn't even pay attention to the stuff I sent you, so you're wasting my time and yours. You could have already figured this out ahead of time. Instead, you asked me to take time out of my day (probably during work hours) to ask questions whose answers I've already provided.
(Please note that this only really goes for non-entry-level positions. For entry-level applicants, such as kids fresh out of college, you may not have very many code samples to work with. That's fine. In that case, send some problems for them to work on at home. Hopefully, these are dumbed-down but real-world problems your company has faced in the past.)
## Phone Screen (aka verifying authenticity)
The first thing you should do is take a gander at my Github profile or my code samples. Then you call me up at a prearranged time and ask me questions about that code. Make me prove that I wrote what I said I wrote.
* I noticed you made this combat simulator (www.bitfalls.com/2013/08/autofight-php-job-interview-task-part-1.html). Walk me through your thought process.
* Your code appears to be a custom MVC. Why did you choose to go with a custom one versus say, CodeIgniter or Symfony?
* This project is an API for Nerd Nite scheduling. First of all, what's Nerd Nite and why did you make an API for it? Second, explain how you scraped the data, organized it, and output the results.
The above three questions will give you way more insight into my programming style and thought process than "What is an MVC?". Please. Don't waste my time. As a senior engineer with 7+ years in the field, I shouldn't need to prove the equivalent of my ABCs to you. It should be understood.
I personally would also skip the whole "live coding" thing via Stypi or whatever. Waste of time, imo. You've already got code samples and you can ask me as many questions as you want about it. I shouldn't need to write code in front of you to establish my credentials.
## What about people who lie?
There are people who lie about their resume and their qualifications, but that's exactly why you should tailor your questions to fit the code samples provided. If I don't get excited about that code and I can't eloquently explain why I did what I did or how it works, then maybe I didn't write it after all. It also gives you an insight as to my personality: I clearly took time out of my day to write this code. Why? What prompted me to write an API for Nerd Nite schedules?
The answers to those questions should give you an idea of whether I can actually program or not. Questions like "What is MVC?" can be looked up in a dictionary. Explaining code samples is much more difficult.
## What next?
Once you've established that I wrote the code I said I wrote, then Step 1 of The Interviewing process is mostly done. Now you bring me into the office to determine Step 2 -- am I someone you want sitting next to you for 8+ hours a day for the next six months? Do I fit in with company culture?
You could give me a problem to solve on the spot, but hopefully it's more of a higher level thing rather than a "write code on a whiteboard" thing. The reason I say this is because at this point you should already have seen my code. You should know by now that I can build a class. The question you need to answer now is: given an arbitrary problem, can I solve it or at least come up with a reasonable thought process?
Bonus points if it's relevant to the job. (i.e., if your job never requires you to write binary trees from scratch, don't ask the applicant to do so.)
## Finally
Between the phone screen (technical) and in-person interview (personal), you should have a good idea of whether you want me on your team or not.
Occasionally for small teams, you may decide that you need to know something about time, creativity, independence, and other similar qualities that you can't really get from code samples. If this is the case, then I suggest doing the contract thing, where you give them an assignment on contract. Once the assignment is finished, you hire them or pay them for the work completed (or hopefully both).
I really, really, really despise whiteboard coding. I don't think it's indicative of anything, and I think you will find a lot of false negatives (i.e., rule out good candidates) using the whiteboard method.
A few other thoughts:
* I should meet my potential future boss at the in-person interview
* I should meet at least one of my potential future coworkers
* Be respectful of my time. Most interviews take place during work hours, so I've taken time off work -- and probably lied to my boss about where I'm going! -- to meet with you. The least you can do is not waste my time.
* Be familiar with my resume and code samples. I took the time to write them, you should take the time to read them. It will answer way more questions about my abilities than a 20 minute quiz on technical terms will.
The more informal the in-person interview is, the better. The technical qualifications should already be accepted by the time I walk in the door. At this point, it's a two way street as we figure out whether we want to work together. I'm interviewing you just as much as you are interviewing me.
(Note: These are just my opinions about how I interview others. It hasn't failed me yet. On the other hand, almost every job I've ever interviewed for has completely wasted my time on that front.)
Oh yeah? Well, if I'm being interviewed, and someone doesn't ask me those questions, I'm going to walk right out!!
This is how we debate interview tactics, right?
Don't walk out on interviews just because you feel your time is so valuable. You're already at the interview. You planned your day for it and started it. Just politely continue 'till the end, you might learn something you didn't know before.
At the most, if you get a way out there question, like, you applied for a dev job and they ask about your proficiency in Microsoft Office, just politely say. "I've used it from time to time. By the way, I've never been asked that question in a developer interview before."...and just continue on. If you think so much of yourself that you're offended by that type of question and abort the interview, I think that says a lot about you just as much as the interviewer.
Hmm, I'm going to suggest to my company that we actually asked dev candidates that question! See what happens! (somehow, I doubt they'll do it.... but it'd be funny to get the reactions).
Are you hiring me to recite textbook definitions to you, or are you hiring me to write code? You can't really have it both ways. By asking me to recite textbook definitions when I've clearly demonstrated that I know the basics (at the very least), then you're wasting my time and your own.
This isn't hubris or egotism -- it's pragmatism. I've already provided the answer, and you're asking me the question again. You should ask me something you can't easily find the answer. Or better yet, ask me a question that answers several questions at once.
You might ask "I noticed on your Github profile you have an application called NaNoWriMo clone. What's that all about?" and I might say "Well, it's an MVC-based application that uses third party API calls to Google Docs using cURL and...."
And you might find that I've answered all of the stupid, basic "What is MVC?" and "What's a POST request?" and "Describe how HTTP works" questions that you would have asked before, except now instead of asking me rote questions that I get at every single interview, you'll find that you're getting the answers to those questions and then some.
You'd be surprised how many 'senior' engineers can't code their way out of a cardboard box.
Background: I've interviewed hundreds (if not thousands) of engineers.
Can you give an example of something you've seen. I just keep hearing about people who can't do fizzbuzz, but how bad are people really? Or what is it that makes these engineers so bad? How have they lasted in the industry?
that said i feel you. tbh, i have managed to impress anyone i worked with. most were people i met at hackathons, people that wanted to bootstrap their startups or general referals. on the other hand I failed most interviews i took(with a few noteworthy exceptions)
It once took me until after the interview to figure out that the guy just wanted to find out whether i understand how variable scopes work.
A lot of interview questions are questionable at best, and most code challenges are even worse. they're exactly how universities teach programming. The only problem is that universities suck at teaching programming. I know a lot of really awesome people that went to university because they thought knowing the topic they study was a good idea, but it turned out to be the opposite.
But one lady once asked me is there a special command to find out where traffic goes? I said route. Is there any special flag you would use she continued. But what she wanted was to hear route -n.
I'm pretty sure in those kinds of interviews they think i'm an idiot
I'm generally happy if they don't ask any questions and write a simple interest calculator. Most people ask some questions about when interest is calculated during the year. Then, if the questions haven't gotten us there yet, I ask them to modify it to a compound interest calculator where you can also contribute some money every year.
I've never had anyone who didn't understand the concept or what I was after. Or at least I didn't have anyone who admitted to still not understanding how it worked.
Two people stand out.
One of them immediately tried to write a recursive function and got lost. Then started over and tried to calculate a one-liner to do compound interest without looping. Couldn't get it, started over with a for-loop and failed to return in the proper place: the code was returning a value and then immediate next line was more calculation.
The second let me explain the problem and then said "I'm sure there's some library call for calculating compound interest, I'm just not sure what it is." Full stop. I explained that I wasn't asking for the library call, I was asking them to work up the algorithm and write code that did it.
They repeated the statement that there was a library call for it but they didn't know it and that if the interview was going to be about the specifics of library functions then it wasn't going to be a good interview.
In both cases these people passed a phone screen focusing mainly on experience, algorithms, design, etc... Since then I've adapted the phone screen to cover more of Steve Yegge's points [1] and I actually include a small coding question on the phone.
I don't think my system is perfect, but in the last round of hiring the people who made it through the screen were almost all good technically and weren't offered positions because of fit with the team. I'm sure there were a few people who might have been good that got filtered out by writing code over the phone but at the time I was willing to risk that vs the time commitment for the rest of my team to do on-site interviews for someone that could be DOA.
[1] https://sites.google.com/site/steveyegge2/five-essential-pho...
They've lasted because they've usually only had one or two employers, as a permanent employee (rather than a contract) and no-one code reviews until it's too late.
Have you also followed up on those failed interviewees to verify that in a real world setting they cannot perform?
If you haven't, then all I can see is a statement of "I have a standard very few can meet".
Do you have any pointers on weeding these candidates out? Our country's employment laws make it hard to fire net negative producing programmers.
> perfectionism seems to be a common thread to not delivering in my (limited) experience
I'm afraid I'm the engineer being described here. I pride myself on technical excellence, theoretical understanding and practical experience with lots of different technologies.
Yet my work history mostly consists of an unbroken trail of unfinished projects and undelivered deliverables stretching back decades.
How can I cure myself of this? Or should I switch careers?
No code sample? Get some. Won't provide some? Don't bring them in for an interview.
The point I'm making is that you can pre-qualify candidates in a LOT of ways before you even bring someone into the office. If I get into your office and you ask me dumb, basic questions, then you haven't screened me effectively. You should theoretically be able to make those determinations before I ever step through the front door of your office.
That seems like a reasonable idea, but we've tried that before, and it's just a terrible filter. Let me try to make a more general claim: anything that lets the candidate have outside resources or unlimited time is going to be a bad filter. In this case, the candidate can prep the code sample and be able to explain it well.
And what do I do if I don't like to release my code publicly? Should I not be hired by any company if I'm not personally a fan of open source (hypothetically)?
I don't think candidates should be excluded based on the lack of a github repo.
If you refused to send me code samples, I wouldn't bring you in for an interview.
1) Work for a company that does not allow you to post code that you write at work (fairly common)
and 2) Don't have time / don't want to spend time on homework for an interview
Combined with: a) Do not code for fun at home
or
b) Code for fun, but in something so completely unrelated that it's not useful (8 bit microcontroller code, say)
or
c) Code for fun, but not seriously with any kind of quality
If you gate your interviews on who has public code repositories, you're missing out on a LOT of qualified people.
The candidate was understanding, and did it - he didn't have to have exact syntax, I was happy enough seeing psuedocode since I already took a peek at the Github profile that was a part of his resume.
It only wasted a few minutes of his time whiteboard coding, and it wasn't intense, so it gave him a nice easy way for him to explain his thought process. I asked relevant questions to the code that he wrote, and it lead to a good discussion on some things.
I felt that we were mutually happy with the experience, as he subsequently accepted our job offer.
On the whole though, asking stupid questions is a waste of both side's time.
IMHO, there's no need for whiteboard coding.
Having said that, if you are going to ask me to do some whiteboard coding, I would greatly prefer something like you described -- a high level response that tests my thought processes. You can see my code on Github, I shouldn't have to write some on a board. But I'll be happy to explain thought processes while solving a problem.
Not that I would have minded coding on the fly or answering stupid brainteasers - I grew up figuring those things out. Those leave me with negative impressions of the company though, and may lead me to demand a higher salary to accept a position.
Very good point, though.
As mentioned, I'm a bit skeptical that an interviewer can reliably extract that information.
I will send you code samples or show you my contributions to open source projects so that you know I can code, happy to discuss these until you are happy.
What is far more important is to find out about me, do you like me, can you work with me & tell me honestly about your dam culture - do you expect everyone to be at there desk at precisely at 8am, work a minimum of 80 hours per week? How is productivity measured? Do you expect me to attend some "team building" weekend nonsense when I could be spending time with my wife instead.
As an entry level applicant, I can't stress how important this was to gaining insight into both how I function when given a deadline and what kind of work is in store for me. It also lets me know what I might need to study in the future or what I need to study immediately.
Of course this requires that you design the question in a way that is not completely google-able, but real world programming is not just about solving a trick question but being able to be resourceful enough to find a real working solution.
But you know, interview is hard. I also think interview questions don't have to change a lot. I heard Box always asks people to design an evaluator. I thought that wasn't so hard but when I started thinking about an evaluator, I started getting distracted by all the cases, even when I wanted to just implement a state diagram.
So I told them. "Look, I did this problem on my own a little while ago." They chuckled and made it harder, which was fine. :-)
There are some serious benefits to bringing up your prior exposure to a question in a positive light. When sending out problems interviewees are likely to encounter again I include the group's "déjà vu guide" http://codingforinterviews.com/seen-question-before
def reverse(str):
left_ptr = 0
right_ptr = len(str) - 1
middle = len(str) / 2
while left_ptr <= middle:
# swap
temp = str[left_ptr]
str[left_ptr] = str[right_ptr]
str[right_ptr]= temp
wouldn't this create an infinite loop? You're never incrementing / decrementing left_ptr or right_ptr.str[0] = ... will trigger an exception
"Double the length of the old string and then cut it in half" isn't against the rules, right?
def reverse(str):
return str[::-1]
Am I missing the point ? def reverse(string='abc123'):
for pos in xrange(-len(string)+1, 1):
string += string[abs(pos)]
return string[len(string)/2:]
Fair?1. How you process information. I'm not going to be impressed if someone at the table says 'Microsoft' and you cringe. 2. Can you admit to not knowing everything? You'd be shocked how big of an issue this is. 3. Are you willing to adapt? In a smaller team, you have to bend and be willing to take on new challenges.
Definitely including this in next week's Coding for Interviews newsletter.
Edit: Annoying that you cannot try practice questions without logging in though.
This is really very true in the corporate world. The better you know how to communicate, the more likely it is that you will succeed in your chosen profession.
There's a simple solution that requires no additional space.
Disclaimer: Code is not tested or given the love it deserves.
Class Item():
def __init__(value):
self.value = value
self.next = None
self.next_largest = None
Class maxStack():
def __init__():
self.top = None
self.largest = None
def push(value):
i = Item(value)
i.next = self.top
self.top = i
if value >= self.largest:
i.next_largest = self.largest
self.largest = i
def pop():
v = self.top.value
if self.largest == self.top:
self.largest = self.largest.next_largest
self.top = self.top.next
return v
def getLargest():
return self.largestPUT http://www.interviewcake.com/api/v1/viewings/ 403
(FORBIDDEN) angular.min.js:99
(anonymous function) angular.min.js:99
n angular.min.js:95
l angular.min.js:94
DjangoRESTResource.(anonymous function) angular-django-rest-
resource.js:12
DjangoRESTResource.(anonymous function) angular-django-rest-
resource.js:18
$scope.updateViewing base.js:31
$scope.markAsComfortable base.js:13
$scope.feelExpertPress base.js:15
(anonymous function) angular.min.js:72
(anonymous function) angular.min.js:144
e.$eval angular.min.js:88
e.$apply angular.min.js:88
(anonymous function) angular.min.js:144
x.event.dispatch jquery.js:5095
v.handle
Sorry about that!
Author of the site wrote solutions in Python, but obviously he/she doesn't understand Python. Isn't that against what the article suggested?
We segment our interviewing into different sections. One person will do a specific functional competency evaluation which consists of writing code in an IDE to see whether you can write code. This portion of the interview is not about analytical thinking skills, people skills, or "tell me about a problem you've solved". It's about writing code. The interviewer is looking to see how many hints you need to get at working code, how well your solution is structured, and getting an overall feel for how you program.
That's a good idea I'll adopt. It looks messy when you start trying to shoehorn in a missed line somewhere.
Also, someone should develop a vim & emacs clone with super big font so it'd be good on a big-screen for coding-interviews.