Coding Interviews: The Hiring Manager’s View

Ahh, the infamous coding question. The very idea that a candidate might be asked to code during an interview caused some furor among commenters to a recent post by my colleague Dawn Kawamoto. I thought I’d provide a hiring manager’s perspective.

Confession: I ask at least one coding question of anyone who will be writing code. Here are the two major points you should know about it.

It’s Not About The Algorithm

It’s about solving a problem, not implementing a pattern.

I ask a coding question to see how you solve problems. Depending on the job you’re applying for, using some known algorithm might be the right approach, or it might not. What I really want to see, though, is whether you get to that algorithm.

After all, algorithms and patterns are generally relatively easy to find. There are libraries that implement many of them, and there are textbooks that tell you how to accomplish them in numerous languages. The hard part is knowing when it’s right to use a particular pattern or algorithm.

This means that the coding questions I ask won’t be, “Can you write a quicksort algorithm?” Rather, I’ll ask a question like, “We’re doing a project involving language analysis and want to look at phrase frequency. Can you write a utility that takes a list of phrases and orders them according to how frequently they’re used?”

A good answer will probably involve using a quicksort implementation. But what I’m most interested in is whether you recognize that. I’m looking for things like how you structure the code, how you approach the problem and what patterns you choose to apply. Unless this is a job where you’ll be implementing algorithms, then you’re welcome to actually perform the quicksort by calling qsort() or equivalent.

It Matches Your Job

Second, the question matches the work you’ll do. If you’re getting hired as a front-end JavaScript/CSS engineer, I don’t think it’s relevant to ask you how to work with b-trees. If you’re being hired to work on indexing and big data parsing, then I’m not going to ask you how many piano tuners there are in the U.S. (OK, I’m probably not going to ask anyone that!)

Why We Do It

I think it’s fair to find out how you think in ways that will be relevant to your job. For example:

  • For a front-end CSS designer: I hand the candidate a picture of a three-column layout and say I want lines between each column that extend to the bottom of the page. This is a problem that calls for equal-height columns using CSS — a common pattern with a number of solutions, some more liquid than others.
  • For a job requiring a lot of data parsing: I ask the phrase-sorting question above. Candidates who specify a bubble sort, or fail to consider that at high volume the sorting algorithm matters, are probably not going to do well.
  • For a job building a website that takes in data from users: I ask a question that boils down to needing to sanitize input data. Knowing that it needs to be sanitized is the first hurdle. The second hurdle is doing it in a reasonable way.

None of these questions breaks new ground. They’re all problems that have been around for years and that continue to be problems. No tricks. Just questions.

Do you see why managers use these questions? Tell me in the comments below.

40 Responses to “Coding Interviews: The Hiring Manager’s View”

  1. Interviewee

    It makes a big difference with coding tests to have sat down with example coding exercises in the days before the interview. You’ll come across as more efficient and confident. There are plenty of blogs with example real-world coding exercises that people have either given or had.

  2. Steve Woloshen

    I think the problem with these sorts of questions is that most interviewers don’t take into account the part about the question being “relevant to your job”. I’ve been a software engineer for about 30 years, and I can’t tell you how many times I’ve been asked to calculate the square root of a number. Having built missile guidance systems for the military and trading systems for Wall Street for three decades, I can honestly say that the only time I’ve ever needed to calculate the square root of a number was on an interview.

    Your approach is valid. Sadly, most interviewers don’t know how to apply it.

  3. Hmmm when doctors and lawyers and judges and senators and cops start taking then i still wont to work for ilk like this countries corporate liars and idiot managers. better yet let the interviewee ask some simple questions of the corporate shill.

    • At least doctors, lawyers, and cops have to go through a standardized process that ensures a certain level of competence before they can even be considered for a job. Software developers just need a good résumé writer, and enough companies out there are just interested in billable seat-warmers to get them “relevant experience” to fill those resumes.

      I’ve worked with people who had advanced degrees in CS who couldn’t implement even simple requirements.

      Politics is probably the only field with a lower bat for entry than software engineering.

  4. Well having had 6 years of higher education I’ve taken many tests.

    I guess these empty suit (suit? perhaps not) managers feel qualified to ask some stupid question. I’d hate to work for a d*ck like that.

    Having said that, my wife is a psychologist. I have learned over the years that a test must be given to a wide range of people, before any VALID conclusions can be drawn from the test. So a question or two, or those horrible Taleo tests, have no satistical validity.

    The US is in the process of destroying it’s own people. All for a buck.

  5. Clinton Staley

    I’ve been both a CS professor and a hiring software manager at various points, and I *always* ask serious programming questions, and filter fairly heavily based on them. They needn’t be complex; I’m more interested in how quickly, elegantly, and accurately a candidate can code something simple.

    The variations in coding ability are HUGE, and are not well-correlated with experience. I routinely encounter developers with years of experience who are less than half as productive as one with only a year or two. I’ve encountered recent PhD’s in computer science who claimed in interviews to have written “50,000 lines of C for my thesis on Markov chain based image analysis”, who when actually tested could not write a single line of coherent code — even cheated in phone interviews by stealing code off of websites when asked to write it themselves. So, the watchword when it comes to coding is “show me”.

  6. TopCoder

    I would easily solve any of those coding questions. That’s the easy part. As a TopCoder I have many opportunities and I have my choice of jobs to take. The question is, can you answer my coding questions? I only want to work with the best, and after I pass your test, if you cannot pass mine I will bid you a good day and take another position. Only for reputable, first rate companies with a long track record of remarkable success will I chose not to ask my coding questions during an interview.

    • codingguru

      Topcoder, I totally agree with you. I always ask a coding, design or technical question for every question I am asked. That gives me an idea of the caliber and knowledge of people I will be working with.

  7. Proud Paulbot

    Ironically, I, the dirty dog walker who is unemployable in IT, completely understand the notion of preemployment testing that is relevant to the position.

    Before I made the mistake of attending college, I spent years working in secretarial, copywriting and proofreading/editing positions. I took many typing, writing and proofreading/editing tests. I never minded doing so. Although I didn’t always get the position, I always passed the tests.

    What I couldn’t stand was being handed the MMPI, or being asked absurd questions like how many [insert occupation here] are in the U.S., or what kind of fruit I would be. It would also tick me off if I were to apply for a $10.00/hour secretarial job and be told I needed to pass a calculus exam to be considered…not because I couldn’t pass the exam, but because that’s just an outrageous requirement for a bottom-level gig.

    I love it. People who are asked to take preemployment tests to prove they’re actually fluent in the languages they claim to be fluent in get angry, yet they get offered jobs. I’d have no problem at all being asked to prove that I’m truly proficient with a particular skill, but I’m unemployable and not capable of doing anything but walking dogs.

    No, there’s nothing wrong with our economy. Nothing at all. Everything is just fine. I cannot fathom how anyone could be that naive and believe that things are getting better, unless they had a psychotic break and just aren’t living in reality anymore.

    • M.Kennedy

      I agree with you Proud, I wished I were asked questions that demonstrated my knowledged of Computer Science instead of taking a test that has nothing to do Programming or Computer Science. I think a lot of people are fed and switching professions. I was thinking about getting a Phd in Computer Science because a love the field so much, but if I can’t make a living, I think I might try to get into medical school were I think there will be demand well into my old age.

      • Proud Paulbot

        From what I understand, a Ph.D., in any field, is worth the investment only if you intend to run a department at a university.

        I’m getting an MBA to keep my undergrad loans in deferment (yes, I know it’s crazy to borrow MORE MONEY when I cannot pay my current debts, but it’s so far gone now that it really doesn’t matter — I just want to buy time). I’m also hoping it will give me some ideas on entrepreneurial opportunities, or at least how to make the most of my petsitting business.

        I wish I’d just gotten a nice, online business degree as an undergrad.

  8. InTheKnow

    You’ve got to understand that Dice is underwritten by many companies who are seeking the lowest paid employee, driving down the wages.

    How many doctors or attorneys have you ever known that has studied and developed new thought processes repeatedly for thiry years as most IT people have.

    Dice is a puppy farm for telling you, to suck it up and take the test.

  9. guns4liberty

    The nature of coding has changed. Managers no longer want creative people to solve unsolved problems anymore. They want programmable drones to connect prefabricated tinker toy patterns
    into solutions. Creativity is gone and good riddance. Just crank out some code and get it to work. Code is no longer an art form but a dot-matrix printed version of the Mona Lisa.

  10. Robert Forillo

    I have taken and given these tests.
    The resume, if honest, shows a knowledge. The test shows ability to apply.
    Many times though a solution is not “brand new”. It is derived from other snippets of code, forums. books, reference manuals, etc. These are all acceptable in coming up with a solution.
    More importantly than coding skill, is what questions are asked about the problem. How is this code going to be used? Qsort in the example, would probably not be optimum, for a word processor type program for a book publisher that calls the routine after every keystroke.
    Also missed was asking questions about utilities.
    I have seen Harvard and Stanford grads that had full scholarships, that were textbook smart and could regurgitate a hundred theoretical answers, but couldn’t write one line of code.

    • Proud Paulbot

      I *strongly* suspect there was a lot of cheating going on at my university. I suspect this because many students turned in their labs, like, 15 minutes after receiving an assignment and get 100%…but yet when an exam was given, the median grade would be ~45%.

      Sometimes I wish I’d just cheated. Then I would have had a 4.0 GPA instead of a lowly 3.1. But then, I’m willing to bet that the people who cheated their way through labs stare at hiring managers like a deer in a headlight when asked to take a test and prove they actually know all the languages they claim they do.

      Reader’s Digest published an article last year about rampant cheating at universities:

      Frankly, I should look into doing what this guy did. I can write, and at this point, I’d have no moral objection to being paid to help losers cheat. It’s a job and it pays money. Lots of money, apparently.

  11. Totally off IMHO.

    Let’s be honest, given the demand by employers to know three dozen frameworks these days, and the ‘autocomplete’ function along with the F1 key, you are very very very unlikely to find people that can sit down and churn out these ridiculous tests on paper.

    What you really want to find is somebody that understands the architecture, framework, patterns, and can solve problems.

    Finding somebody that has memorized a bunch of GIGO is pointless.

    • Glen Smith

      I agree. Best questions usually will elicit questions from the interviewee, not a point answer. For instance, if the interviewer asks me how I would find the top sales person, my answer should not be the code to do that but the logical questions that would follow such a request.

  12. I am a bit surprised at all the comments against this simple coding test for someone applying for a coding or programming position. If this question or test is indeed unreasonable, then a similar question such as “what would you do” for a project management or procurement position would also be unreasonable. I have met people with resumes claiming they are skilled in 6 or more programming languages but could not pass the simple “test” described in this article.

    • That’s why the FizzBuzz test exists. I think it was Joel Spolsky came up with it, if I remember correctly.

      He had some bad experiences with new hires who interviewed well, some of whom even had masters degrees in computer science, yet couldn’t implement the FizzBuzz test.

      I don’t much like whiteboard coding, but I’ve had a few interviewers have me sit down at a computer and implement some code, which worked out much better than the whiteboard approach. One company wanted a code sample that involved implementing an algorithm, writing some server side code to serve up the data it produced, plus a UI that used Ajax. They wanted all that plus production quality implementation… Which I wouldn’t mind doing on the job, but for an interview process, it’s excessive. I guess that company wanted to hire only people whose entire lives revolved around writing code.

  13. There is a significant quantity of coding that is neither “world changing”, “the next big thing”, or particularly innovative or challenging. It simply requires a competent programmer, not a “ninja”, “guru”, or “samurai”. Therefore, asking a person what type of fruit he or she is, how he/she would escape a salad bowl, or other silliness, is pointless. As a matter of fact, it might be best to show the candidate a real example of past need and ask them “How would you ….?”. That of course assumes the candidate understands the business.

  14. Coding tests are important, but we do it differently. During the interview, we are looking for how someone interacts with a team. We usually ask a architecture question to see how they think and interact. BUT, that’s not sufficient. To understand how they code, we then give a coding assignment to do on their own time and then send back in a few days so we can evaluate it. I don’t care how they code on the board in front of me since that’s not how they will be coding on the job. I want them to take the test with all of their tools and resources and do it in the same environment as they would be on the job. (At a desk by themselves rather than self-conscious at a whiteboard.) We usually give them a couple of problems to choose from and tell them that they should expect to take 4-6 hours to do the assignment. (Usually it’s some kind of node walking problem to find the least weight through a graph, or something like that.) Those tests have been incredibly revealing. For 100% of the candidates we’ve tested, what we see in their sample code is what we see in their real code. When we first started testing, we made some bad hires by not viewing those tests as harbingers of things to come. “Their interview was great. Does it really matter that his code was wrong and his test code didn’t catch it? He’s really smart. Let’s bring him on.” WRONG! The people who did great on the coding tests were great coders. The people who cut corners or were sloppy and wrote poorly structured code on their tests were the guys where were sloppy or wrote poorly structured code in production. I do care about how well someone interviews. But, for coders, what I *really* care about is how well they code.

    • Garry Hurley

      What is that, .Net? How about in Java? What about Object-oriented COBOL? How about Perl? Python? Fortran? RPG? C? awk scripting? I could go on and on with multiple languages. Your ‘Done’ statement makes assumptions that may not work. If the company is a UNIX shop, your assumption of a .Net language is useless, as .Net is a Microsoft technology. If it is a mainframe shop, it is equally meaningless. Of course, that simple code fragment might be enough to satisfy a .Net shop.

  15. Garry Hurley

    I have a different opinion of coding tests. I have not done professional development in the past four years. I have been unemployed for four months now. When I get told by some hiring manager that I don’t know how to program because the knowledge seems to have mysteriously evaporated from my mind while I was not using it, I demand a coding test. I demand the right to show them what I am capable of doing. Instead, I get ignored. Why? The answer is simple. The hiring manager is just not qualified to hire people who know what they are doing. Too often, the person conducting the interview is trained in human resources management, and is just there to filter out the ‘unqualified candidates’ before the actual hiring manager gets a chance to look at them. This means blindly looking at the resume and finding any excuse to eliminate an applicant before the qualified people see his resume. That is why you get people with impressive credentials who cannot write a single line of code. The thing is, it makes it harder for those of us who do know how to code in multiple languages to get a job. We have to beg for a chance to show our skills, but the people we are showing would be impressed by blinking text and animated GIF images. Yes, I know I used an HTML reference rather than coding, and did so to illustrate how unqualified HR people are (as a general rule) to review IT credentials. For those HR people out there reading this and getting insulted, do not take it as an insult. I am merely pointing out that your industry does not provide you with the necessary knowledge to do your job properly. As to the comment about doctors not needing to take a test to get a job, maybe they should. It might cut down on the number of malpractice suits we have in this country, and let me tell you, I wish more nurses took some sort of test – especially on how to find a vein for an IV.

  16. The author sounds like a sensible interviewer. Unfortunately, she is in the minority. The vast majority of interviewers I’ve encountered are either other developers (not trained for interviewing) or managers who seem to follow a one-size-fits all interview script without tying any of it to actual relevance to the job.

    The other point I’d make is about the practice of bringing in a candidate to interview with 4 or more people back-to-back. So, the author asks a coding question. Does the next person in line ask a coding question too? I have been to on-site interviews and endured 6 hours of whiteboard coding because each interviewer had his/her own coding exercise. This is crazy.

    Having been on the hiring side, I recognize that it is imperative to have a candidate do some coding. But once you’ve checked that box you move on. When we bring in a candidate, we have 3 or 4 people at the same time witness the whiteboard coding so that they all see the same thing, and so the candidate doesn’t have to repeat the coding over and over again. Then we have individual sessions that delve into different aspects of suitability: architecture, versatility, work style, etc. Since it’s coordinated, each interviewer probes something different.

  17. I am a big believer in honest assessment of a potential employee’s worth to prevent a “bad fit” job situation. Whether that’s an actual coding test in the language needed or a series of questions and answers, it’s a good way to assess the person’s competence, discipline, attention to detail and ability to listen, to name just a few.

    And for the record: I was a mainframe programmer (COBOL & JCL) for 27 years. My career was very successful and continuous until 2008/2009 when my job went to a firm headquartered in India.

    In 2009, I spent a lot of money to retrain in .NET technology, wound up almost immediately thereafter in one of those “bad fit” jobs, was let go, and decided to buy a business with my husband in another state.

    I’m back and doing some retraining and getting a surprising amount of interest for someone who has zero job experience in IT since 2009. I won’t give up until I have a steady paycheck. Many people admire this.

    Like everything else, life is what YOU make it.

  18. I find all of these task useless. I have been an Engineer for over 35 years and have taught at the University for over 19 years part time and I can’t tell you how many students can Ace tests and coding exercises, but when given a real world application could not find their way out of a paper bag that had no sides. I’ve been told that hiring managers have been burned by people who have lied on their resumes, I submit that these managers need some courses on Interview skills. I do not know of anyone of my coworkers in any company nor myself who hasn’t been able to determine the competance of an applicant by just a normal interview. I could turn it around and ask the manager a question to determine their though process on then projects I have been involved with and they would fail, then would complain that they were not hired. References are also a good point and yes, I have given poor references to someone who was not competant.

  19. I just went through a disgusting interview process; multiple interviewers, back to back.
    I get 60 minutes with this recent PhD. He spends 50 minutes telling me how great he is then asks me to hit the white board and design a library inventory checkout system. In 5 minutes? Right. Do you have a spec? No, make one up. I laughed at him. (My career started before he was in diapers)
    At the end of day I asked his manager if he knew what the PhD did all day. No clue.
    Needless to say, I didn’t get the job.
    Needless to say, I didn’t want the job after seeing that.

    Managers, it goes both ways. A poor interviewer can chase off a very qualified candidate.

  20. payamazadi

    About the initial interview question posed. Quiksort is a lame idea. If you have a list of phrases, hash them out or use a map with a counter, then make a heap/priority queue out of it. The way you arrive to the algorithm is by working backwards – you need a structure that is effective at ordering data, not a system to order it. Assigning value and assigning order are two different things. I think the level of compsci education needs to vastly improve. I’ve interviewed people with 30+ experience who don’t know any compsci at all but have had successful CS careers. I’ve interviewed people with 2 years experience who don’t know any compsci. I’ve had a recent undergrad tell me the asymptotic complexity of search in a binary search tree is 3.

    You can neither judge people by their resumes nor by whiteboarding code. Personally I think whiteboarding code is an egregious waste of time and effort. I suck at it, but I’m a good coder. Other people are great at it, and are terrible computer scientists.

    This thread has made me realize how negatively the industry has impacted the market. I’ve seen it at job fairs (I’m a recent grad) – the companies almost never send compsci people to recruit. They send HR people who don’t know anything about.. anything. At all. It makes my vision very jaded.

    At Microsoft HQ I had to whiteboard code and failed. As it turns out the interviewer didn’t explain the organization of ASCII correctly to me the first time – the test was to implement a backspace function in C when there are extended 255 bit ASCII characters available. At their on-campus interview before that, I had to write code to figure out which 2 numbers in a given list sum to a given number. That was very basic, I think that’s OK.

    I think if you’re interested in screening resume liars, ask sanity-check questions. Amazon asked me to come up with a garbage collection algorithm – basically you have to take a look at the stack and the heap and do a set difference (how?) That seems useless to me. I’d rather ask someone how he’d write classes to implement animals in a zoo program. If he doesn’t say any of: inherit, subclass, or extend – he doesn’t know OOP. I’m not interested in how well he can write the class and the attributes or if he can remember the syntax. Just that he knows he needs an Animal class and then subclasses.

    Also in this market I’m surprised so many companies do such insanely rigorous interviews.. it’s because the labor supply has been flooded with morons claiming to be compsci people – or people who think they are compsci people, not realizing just how monumental of a statement that is. I feel like if I get too rigorous in an interview people will just blow me off.

    On a final note, most companies neglect culture fit. A lot of these “bad hire” positions on this thread and in other posts on Dice come from lack of culture fit. Different companies will pursue different recruiting and interviewing strategies that reflect their culture. An interview is a time for you to interview someone, AND for someone to interview you. The mutual fit is what’s important – not whether they can do the job you want and you can shove enough money down their throat for them to take the offer.

  21. Is it OK to post code? This one did not earn even anything…

    int main (void)
    screen_t theScrn;
    int i, j;
    int okTestCnt = 0;
    int wrongTestCnt = 0;


    testAcrossMatrix(&theScrn, -1, 0); /* Call with parameters that fail */
    testAcrossMatrix(&theScrn, 5, 5); /* Call with OK parameters */

    for (i=0; i <= SCRN_X; i++) {
    for (j=0; j <= SCRN_Y; j++) {
    if (0 == testAcrossMatrix(&theScrn, i, j))

    printf("Stat results: The number of OK test results is: %dn", okTestCnt);
    printf("Stat results: The number of wrong test results is: %dn", wrongTestCnt);

    return 0;

  22. Great post with even greater comments. Very insightful. I took and passed a test to work for EA Sports. I liked the test, it verified I knew how to code and wasn’t super hard. Its been a couple of years since I got my degree and I don’t have all the sorting and searching algorithms committed to mind. I’ve been asked to whiteboard at Microsoft, Amazon, Goldman Sachs, Qualcomm & all the other places I interviewed when I was in the job market. Every interview was the same. 6 back to back coding interviews that tested different coding skills. I don’t live & breathe code so maybe I wouldn’t be a fit for these jobs, but I’m a knowledgeable engineer. I’ve also conducted several new hire interviews and I’ve never been properly trained to interview. I think what is highly needed is highly trained interviewers who know what skills to look for, as well as team fit.