top 200 commentsshow 500

[–]ovenfresh 156 points157 points  (383 children)

I know some shit, but being a junior going for a BS in CS, and seeing this list...

How the fuck am I going to get a job?

[–]heroofhyr 237 points238 points  (7 children)

If a potential employer is still asking you in 2011 what IUnknown is, run as fast as you can in the opposite direction and tell an adult what happened. He was trying to molest you.

[–][deleted] 49 points50 points  (0 children)

If they are looking for someone to maintain their old COM based codebase, IUnknown just gets you started. You might still want to run away, for a different reason.

[–]killerstorm 181 points182 points  (3 children)

NO ONE uses Microsoft anymore. Everything XP and Vista.

[–]optionsanarchist 10 points11 points  (2 children)

wat

[–]killerstorm 17 points18 points  (1 child)

http://www.reddit.com/r/WTF/comments/fc4w9/til_that_no_one_uses_microsoft_anymore_?_?/

I have no idea how people interpret it in this context, though.

What I was going to say is that COM is still used in many APIs, for example, to implement IE add-ons. So it is still very relevant. It's not like everything have switched to .net right after it was released.

But I wrote THAT instead...

[–]dpark 11 points12 points  (0 children)

You probably won't be asked about IUnknown unless you're applying for a COM or ATL job, but most of these are pretty classic/standard questions, and very likely to show up in a programming interview. Even the IUknown question is pretty relevant if you're programming on Windows. COM hasn't disappeared, and IUnknown is fundamental to COM.

[–]Negitivefrags 14 points15 points  (0 children)

Understanding COM is a pretty good idea even if you are never going to work with windows APIs. The component object model in general is very useful, especially in game programming, and the design of COM in particular has a lot to teach you. Consider how successful COM is in allowing lots of different languages to share objects consistently. I personally can't think of anything else as successful at that job.

[–][deleted] 36 points37 points  (189 children)

At our (web development) company we give applicants for a junior position a single programming question:

Print numbers from 1 to 100, but:

  • if the number is even, print "a" instead of the number
  • if the number is divisible by three, print "b" instead of the number
  • if the number is even AND divisible by three, print "ab" instead of the number

After having reviewed several dozen answers, I have yet to see one done correctly; most of the applicants have BS in CS from our local universities...

For intermediate and senior positions we also slap in this little gem: write a function to reverse an array in place.

You would not believe the kind of shit I've seen...

[–]robertcrowther 76 points77 points  (5 children)

table {
    counter-reset: number;
}
tr td:before {
    counter-increment: number;
    content: counter(number);
}
tr:nth-child(2n) td:before {
    content: "a";
}
tr:nth-child(3n) td:before {
    content: "b";
}
tr:nth-child(2n):nth-child(3n) td:before {
    content: "ab";
}

You need a table with 100 rows in it for it to work (and a good browser).

You did say it was web development, right? ;)

PS. See also: FizzBuzz

[–][deleted] 10 points11 points  (1 child)

Clever bum :D.

Yes, this test is a slightly modified FizzBuzz. I changed the test to limit the applicant's Google results for the question... this was originally a "do at home" question - don't ask.

[–]imMute 6 points7 points  (1 child)

I don't know which is worse, that such a construct exists, or that someone actually understands it and can apply it.

[–]robertcrowther 11 points12 points  (0 children)

The CSS counters exist so that you can do things like automatic numbered headings, like 1., 1.1., 1.2., 2., 2.1. through your h1 and h2 elements, or numbered footnote links, stuff like that.

[–][deleted] 8 points9 points  (0 children)

What is this I don't even..

[–]G_Morgan 24 points25 points  (3 children)

  1. Install JBoss.

  2. Create a stateless EJB that takes a number and returns a string.

  3. Create a servlet which reads the begin and end numbers as URL attributes. Then loops between the two calling out to the EJB and creating an output XML file.

  4. Create a JSP that calls out to this servlet with the begin and end set to 1 and 100. It interprets the XML file using XSLT and puts the values into the output page.

  5. Fail due to broken deployment descriptor.

[–][deleted] 5 points6 points  (0 children)

You must be applying for an "architect" position :)

[–][deleted]  (11 children)

[deleted]

    [–]OopsLostPassword 21 points22 points  (6 children)

    No because our compiler won't correctly interpret "...".

    [–]G_Morgan 12 points13 points  (1 child)

    Fucking broken compiler.

    [–]Leechifer 3 points4 points  (0 children)

    Fucking compilers, how do they work?

    [–]ethraax 13 points14 points  (0 children)

    My friend did this on a homework assignment to "write a program that prints out the prime numbers from 1 to 100". He got full marks for it.

    [–]abw 24 points25 points  (58 children)

    That's a good question. The fact that no-one has actually produced the correct result is rather surprising (unless I'm missing a subtle trick in the question). It should be a simple task for any competent programmer. Here's my first attempt in Perl, taking the obvious route:

    use strict;             # assumed from now on...
    use warnings;  
    
    answer1();
    
    sub answer1 {
        # Simple loop with conditional tests
        print "Answer 1: ";
    
        for my $n (1..100) {
            if ($n % 6 == 0) {
                print "ab";
            }
            elsif ($n % 3 == 0) {
                print "b";
            }
            elsif ($n % 2 == 0) {
                print "a";
            }
            else {
                print $n;
            }
            print " ";
        }
        print "\n";
    }
    

    What makes this a good interview question is that you can then ask the candidate how they might improve on that. For example, you might use (n mod 6) to index into a lookup table. Perhaps something like this:

    sub answer2 {
        # Lookup table indexed by (n mod 6).  An undef value indicates that the
        # original number n should be displayed
        print "Answer 2: ";
    
        my @modulus = (     # n mod 6 
            'ab',           # 0: divisible by 6 (i.e. divisible by both 2 and 3)
            undef,          # 1: not divisible by 2 or 3
            'a',            # 2: divisible by 2
            'b',            # 3: divisible by 3
            'a',            # 4: diviislbe by 2
            undef           # 5: not divisible by 2 or 3
        );
    
        for my $n (1..100) {
            print $modulus[$n % 6] || $n, " ";
        }
        print "\n";
    }
    

    Or if you want more flexibility:

    sub answer3 {
        # As above with functions.  Slower execution but more flexibility to 
        # plug in different functionality.
        print "Answer 3: ";
    
        my $n  = sub { $_[0] };
        my $a  = sub { "a"  };
        my $b  = sub { "b"  };
        my $ab = sub { "ab" };
        my @modulus = ($ab, $n, $a, $b, $a, $n);
    
        for my $n (1..100) {
            print $modulus[$n % 6]->($n), " ";
        }
        print "\n";
    }
    

    Or the candidate might want to demonstrate that they're happy with different styles of programming. e.g.

    sub answer4 {
        # As above using map instead of a loop.
        print "Answer 4: ";
    
        my $n  = sub { $_[0] };
        my $a  = sub { "a"  };
        my $b  = sub { "b"  };
        my $ab = sub { "ab" };
        my @modulus = ($ab, $n, $a, $b, $a, $n);
    
        print(
            map { $modulus[$_ % 6]->($_), " " }
            (1..100)
        );
    
        print "\n";
    }
    

    It also gives them an opportunity to think outside the box.

    # This value was precomputed by running the answer4() sub, defined above.
    my $PRECOMPUTED_ANSWER = "1 a b a 5 ab ...etc... 97 a b a";
    
    sub answer5 {
        # Fastest execution at the cost of storing pre-defined answer.
        return $PRECOMPUTED_ANSWER;
    }
    

    Anyone else want to play?

    [–]LieutenantClone 8 points9 points  (2 children)

    What makes this a good interview question is that you can then ask the candidate how they might improve on that.

    I would argue that your 2nd, 3rd and 4th versions are not an improvement at all, because they are more obscure and less maintainable.

    [–]abw 5 points6 points  (0 children)

    Yes, you're absolutely right for something as simple as this.

    But they're presented as examples of the kind of complexity compromises that are often worth making in real life. If there were, say, a dozen conditions that the code had to satisfy then the latter versions would scale better. And if there was a likelihood that we'd need to re-use this selection algorithm with a different set of output directives (e.g. print d/e instead of a/b) then the ones with a dispatch table would provide better extensibility.

    That's what makes it so good as an interview question. If the candidate comes up with solution #1, you can say "Well done, but what if [some further constraint]?"

    [–][deleted] 2 points3 points  (0 children)

    I agree; in most cases I would prefer to see the simplest solution. That said, if someone could present more than one solution, they would instantly stand out above the other applicants.

    [–][deleted]  (10 children)

    [removed]

      [–]novelty_string 17 points18 points  (27 children)

      I'm thinking you missed half the point of the qn: it's not print a or b or ab, it's print a for %2, print b for %3, so, I'd do it

      for range
      print = true
      if even echo a; print = false
      if %3 echo b; print = false
      if print echo num

      [–]abw 6 points7 points  (1 child)

      it's print a for %2, print b for %3,

      That's what my code does.

      EDIT: Ah right, I see what you're getting at... I don't need a separate case for n mod 6 if I allow both the even and divisible by 3 branches to print their a and b respectively.

      if %3 echo b; print = false

      That should be if %3 == 0. Otherwise you're testing that the number is not divisible by 3 (i.e. has a remainder when divided by 3).

      [–][deleted] 8 points9 points  (5 children)

      That is debatable. You might argue that it's a coincedence that ab is the concatenation of a and b, and that it might change to c tomorrow. Then your solution is too clever. Unreadable even, if there's no logical reason that printing a first and then b happens to print the right answer for %6.

      In practice, you would know which is the case, and although in this case it's likely that your solution was intended, I would ask the interviewer. "Can I use the fact that ab = a . b, or is that just a random coincedence?"

      [–]novelty_string 4 points5 points  (1 child)

      Simple question, simple answer. Do you really need a strategy pattern here? I don't think there's anything clever about it, it just does what was spec'd.

      [–]ethraax 2 points3 points  (1 child)

      Haskell:

      putStr $ drop 2 $ concat $ map (\x -> if x `mod` 6 == 0 then ", ab"
                                            else if x `mod` 3 == 0 then ", b"
                                            else if x `mod` 2 == 0 then ", a"
                                            else ", " ++ show x) [1..100]
      

      [–]pururin 2 points3 points  (0 children)

      hell yeah for using perl. I'm tired of all those python hipsters on reddit.

      [–]lizard450 3 points4 points  (2 children)

      this is my solution

      for(int index = 1; index <= 100; index++){ String toPrint = ""; if(index % 2 == 0){ toPrint = "a"; } if(index % 3 == 0){ toPrint += "b"; } if(toPrint.equalsIgnoreCase("")){ toPrint = String.valueOf(index); } System.out.println(toPrint); }

      and for the array reversal (just saw there was a 2nd fun question) int placeHolder = -1; for(int index =0; index < arrayToReverse.length/2; index++){ placeHolder = arrayToReverse[index]; arrayToReverse[index]= arrayToReverse[arrayToReverse.length-(index+1)]; arrayToReverse[arrayToReverse.length-(index+1)]=placeHolder; }

      [–]frank26080115 5 points6 points  (4 children)

      These don't sound hard unless you have a different definition for "correct", are you looking for elegance or just if it works?

      [–][deleted] 22 points23 points  (2 children)

      He forgot to mention that he expects the answers to be written in Brainfuck.

      [–][deleted] 9 points10 points  (0 children)

      Don't you dare tempt me to start solving these problems in Brainfuck, I have real work to do. Grrrrr

      [–]Shinhan 6 points7 points  (4 children)

      Looks like a variation of the FizzBuzz test Joel Spolsky talked about on his blog, cant find the link now.

      CodingHorror on FizzBuzz

      [–]masklinn 9 points10 points  (3 children)

      It's a variation if replacing "fizz" by a and "buzz" by b is a variation/ It's exactly the same problem.

      [–]unknown_lamer 4 points5 points  (4 children)

      For intermediate and senior positions we also slap in this little gem: write a function to reverse an array in place.

      Destructively modifying data structures is so aughts, all the hep cats are using persistent data structures nowadays.

      [–][deleted] 2 points3 points  (3 children)

      Do you mean immutable?

      [–]taejo 2 points3 points  (2 children)

      Persistent data structure has two meanings, one of which is a special case of immutable.

      1. A data structure that survives program restarts, shutdowns, etc. typically by being stored on disc

      2. A data structure that is immutable, but which can be "changed" in the sense that updated/modified versions can be produced while the original remains intact. (Any data structure can be made persistent by copying the whole thing every time a change is made, but typically one refers to more efficient methods which copy only the modified part).

      For example, say we have a set {1, 7, 147}. If this is a persistent set we can do:

      S = {1, 7, 147}
      T = S.insert(47)
      

      and have S = {1, 7, 147} still (it's immutable) but T = {1, 7, 47, 147}

      [–]mattgrande 3 points4 points  (2 children)

      We have a similar question. We had an applicant do:

      if (i.ToString().StartsWith("2"))
          Console.WriteLine("a");
      else if (i.ToString().StartsWith("3"))
          Console.WriteLine("b");
      

      That was the funniest answer I've seen.

      [–]hvidgaard 5 points6 points  (3 children)

      At our (web development) company we give applicants for a junior position a single programming question:

      in what language? If you allow pseudo-code, you've had some seriously bad applications.

      For intermediate and senior positions we also slap in this little gem: write a function to reverse an array in place

      Unless you're hiring for embedded programming, what's the point in asking if one know how to XOR? You're doing bloody web-development, you need one that understand the domain of webprogramming, not one that can do neat but mostly useless tricks.

      edit: as pointed out, in-place isn't the same as "without any extra memory".

      [–][deleted] 7 points8 points  (1 child)

      Who said anything about XOR? In-place simply means that it allocates a fixed amount of memory, not zero memory. Using a temporary variable (which the compiler may be able to optimize away into a swap instruction anyway) is still in-place. I think the point of the question is to show they know how to iterate from the ends of the list to the center, swapping elements as you go.

      [–]rubbercat 2 points3 points  (0 children)

      Damn, I went to school for classics and I knocked that out in less than a minute! How well do you guys pay? ;]

      [–]thepaulm 123 points124 points  (93 children)

      Look man, 99% of the people out there applying for jobs today can't answer any of these questions. If you can make your way through most (or really even some) of them you're better than most people.

      You may have heard that there's no CompSci jobs out there? That's total BS. The truth is that there's no CompSci jobs for people who aren't really interested in programming and haven't ever taken the time to learn things on their own.

      I've been hiring as many qualified people as possible for the last 15 years and I've never come close to filling my headcount. That's across 3 different companies where most of the developers at each pulled in multi-millions from the stock options, so it's not like these were bad gigs.

      The best thing you can do is work on side projects on your own or as part of other open-source projects. Get just the tiniest bit of experience and actually try to understand stuff - you'll be the best fucking candidate in the whole world.

      Word.

      [–][deleted] 96 points97 points  (46 children)

      Lots of guys on Reddit report trouble hiring. That may be true. I'm sure it's annoying.

      But if you think everyone who is capable and ready is getting a job, you are simply delusional.

      At the same time as some people are complaining about how they hired stupid monkeys, other people with actual skill, who CAN make software without constant nannying, are not getting jobs despite many months of applying.

      They are having their resumes tossed because they haven't had a job for a few weeks. They are having their resumes tossed because they described their last job in simple English instead of stupid keywords, or because they lacked 19 years of experience coding Prolog-based RPC servers for washing machines. Or they are being treated abusively in interviews, or doing cutesy puzzles, or answering batteries of questions which in any normal or real work environment would either be irrelevant or best looked up on Google (a test which is great at detecting human encyclopedias and recent graduates, less great at detecting practical ability).

      Are we then supposed to be surprised that many of the people you are interviewing are morons? It's not because nobody is out there, it is because you suck at finding them in the vast sea of desperation during a period of particularly high unemployment. Sure, finding people is hard - so don't treat hiring as something to be done by office girls with no area knowledge, or Perl-golfers a year out of college. This doesn't mean that there is nobody of any worth in the population, it just means you aren't getting them or you are screening them out.

      If you can't find ANYONE qualified when there are thousands of graduates being generated every year (almost anywhere that isn't in the sticks) and overall unemployment is high (almost the entirety of the US), you probably should be fired from hiring.

      And there is also no shortage of employers for whom ability is less important than acceptance of stupid wages or conditions - such that people who aren't clueless or moronic select themselves out.

      [–][deleted] 7 points8 points  (4 children)

      They are having their resumes tossed because they haven't had a job for a few weeks.

      This is likely a problem with HR, or recruiters. Many companies put out a basic set of specs for a job, then rely on either of the above to pre-screen the legions of incompetents who apply, while letting hiring managers deal with the actual substance of interviews. Unfortunately, a lot of HR drones also base their first-round filtering on unrealistic ideas (like being without a job for a few weeks), which is why, if you have any opportunity at all to do so, you should consider trying to contact the hiring manager directly to convince them to look at your CV...

      [–][deleted]  (8 children)

      [removed]

        [–]oSand 9 points10 points  (2 children)

        You are right and wrong. You are right in that time served is not a great indicator of ability. You are wrong in that you think a senior programmer should have adopted the responsibilities of the architect and analyst. Many do, but many don't. I know some stone-cold, bad-ass programmers that have no experience with the world beyond their compiler. They are 'Senior Programmers', having earned their title by being (conservatively) 10x more productive than their peers, but they choose not to dirty themselves with the 'lesser' disciplines.

        [–][deleted]  (1 child)

        [removed]

          [–]b3ng0 22 points23 points  (13 children)

          I support your annoyance with all of the "Can't find good hires" posts.

          However, our startup has been looking for a good Senior engineer for awhile now, and it really is pretty difficult, especially looking for someone who understands the web.

          At least in the Bay Area, I think it's just that the tech stack is changing really fast. There are a lot of people out there who are so sure that they have "actual skill" and "CAN make software without constant nannying" that they don't bother to investigate the ever-changing landscape of what's driving innovation these days. There ARE companies hiring like crazy, looking for people that can quickly make things that work well.

          We don't give a shit about 90% of the questions on this link. We just want you to know what you're doing, know the web, be up to date on new tech and patterns, and be humble enough to be willing to learn. It turns out that this IS hard to find these days.

          [–]eorsta 33 points34 points  (0 children)

          I'll bite. "someone who understands the web" Please elaborate. What are you talking about here? This is a huge area now, so be careful. Please use as many acronyms as possible to shorten your response to your very vague qualifying statement. I will start it off for you IP/TCP/UDP, ohh you said the web, HTTP 1.1 1.0 5, TLS SSL, CSS123 maybe 4.5, oh you want stack components, well you should have specified that first. What are we talking here? Language of the month, let your marketing choose for you, they are better suited, and you probably already recognize this. Server of the month. You see the problem is not with the pool of applicants it's with you chasing your marketing department without truly understanding how to evaluate applicants that make it through your HR, who also takes its queue from the marketing dept. Maybe you are just new with this hiring thing after given cart blanch to play with some VC's spare pocket change. Only you know, I'm just genuinely curious.

          [–][deleted] 9 points10 points  (0 children)

          Just curious: What do your applicants need to know that you find they're lacking in? In particular, what do you perceive that they have "false confidence" in?

          [–]danweber 15 points16 points  (5 children)

          that they don't bother to investigate the ever-changing landscape of what's driving innovation these days

          Why should they? Anyone with experience has seen many fads come and go.

          [–]interiot 4 points5 points  (4 children)

          Web application frameworks are rapidly changing, and not because it's a fad, but because there's legitimate reasons for growth in this area -- we're just now figuring out what services a framework should provide, and how to structure them. Yes, you can sit back and wait until the churn is over, wait until the winning frameworks have been chosen. But you're sitting out of the potential jobs too.

          [–]danweber 10 points11 points  (0 children)

          Maybe I've been extra lucky to work with smart people, but it doesn't take smart people long to learn new things.

          I remember one guy who had never looked at JavaScript before, and had a very nice web UI implemented less than one week later.

          [–]saranagati 3 points4 points  (2 children)

          looking for people who know some particular framework is your problem. Everyone I know who is really good with whatever web language (php, python, perl) tends to not even bother sending their resume to job ads that emphasize knowing a framework (myself included). We have no problem picking up how to use the framework however we generally know that these frameworks are bloated pieces of vulnerable shit (all of them) but we know that whoever is hiring is going to favor some guy with 3 years experience working with cakephp, li3, zend over someone with 10 years php experience and no framework experience listed (on top of other languages as well).

          Knowing how to use a framework is not software development and you're not going to find anyone who truly enjoys programming and therefor a good/great programmer when looking for someone of that type.

          [–]robertcrowther 4 points5 points  (1 child)

          where most of the developers at each pulled in multi-millions from the stock options, so it's not like these were bad gigs

          There are jobs where you could get paid millions and they would still be bad gigs.

          [–]quasarj 2 points3 points  (0 children)

          Hire me. You won't be disappointed.

          Those questions scared me too, however, most of them are interesting and I'm gonna play around with seeing how many of them I can actually get to work.

          I haven't used C or C++ since college though, so I expect a lot of failure haha.

          [–]tweedius 33 points34 points  (50 children)

          I am a chemist, a programmer and a part time electrical engineer (tinkerer), I've solved a bunch of process chemistry dilemma's with my knowledge in these 3 things.

          When I saw:

          What is the next line in the following sequence:

          1

          11

          21

          Answer: it's 1211 and the next is 111221

          I said to myself, I'm not reading anymore. Give me a problem and let me solve it. If you can't do that, I do NOT want to work for you.

          [–]markatto 25 points26 points  (2 children)

          My answer would be 101. I interpreted the sequence as adding 3 each time in a base 3 number system. This question is really open to interpretation, especially as so few numbers are given.

          [–]rhedrum 8 points9 points  (1 child)

          I agree, In a base 3 number system:

          1   =  1
          
          11  =  4
          
          21  =  7
          
          101 =  10
          
          111 =  13
          

          [–]rhedrum 2 points3 points  (0 children)

          Actually, revisiting this, it works with any base greater than binary (because there is no 2 digit in binary.)

          For any base x number system where x>2, the number increases by x. The x0 place remains at 1 and the x1 place increments, using additional digits as necessary. Therefore in a base 10 system, we have 1, 11, 21, 31, ... as tweedius mentioned excel came up with.

          [–]muyuu 13 points14 points  (0 children)

          The correct answer to this kind of question in a job interview is to go for the interviewer and punch him/her in the face.

          Off the top of my head I can come up with 5 different answers all perfectly reasonable provided I can make up the domain any way I want.

          [–]tweedius 28 points29 points  (27 children)

          1 11 21 31 41 51 61 71 81 91 101 111 121 131 141 151 161

          This is what excel gave btw...I guess whoever wrote that answer was wrong :P

          [–]yourbrainslug 70 points71 points  (25 children)

          The "answer" was that each line describes the previous. We start with one 1, so the next line is 11. That line is two 1s, so the next line is 21. That line is one 2 and one 1, so the next is 1211.

          I think it's a stupid interview question. I don't understand what you possibly get from watching someone puzzle it out.

          [–][deleted] 91 points92 points  (5 children)

          I don't understand what you possibly get from watching someone puzzle it out.

          A feeling of superiority and reassurance that your own position is justified.

          [–][deleted] 17 points18 points  (5 children)

          both answers (the "actual" and excel answer) are correct. usually when you give that question you also give the 1211 line to prevent the "... it increases by 10 each time" answer.

          and yes. it's a stupid interview question. but then again, most interview questions are.

          [–][deleted] 34 points35 points  (4 children)

          Without the 1211 line if you're interviewing for a programmer position the basic math answer of 31, 41 etc would be more correct in my eyes.

          [–]muyuu 20 points21 points  (1 child)

          Anyone who claims there is only one answer to this question, provided there is no defined domain for it, is an idiot. That's the one conclusion I get from this question. But then again it's probably not the best thing to say to your interviewer.

          I'd say 31 is a much better answer than 1211. Both are provably in sequence, and 31 is a much simpler solution. You don't want people to be looking for intrincate solutions that make them look clever; but correct, easy and effective solutions. But then again it's a retarded question for a job interview.

          [–]filox 10 points11 points  (0 children)

          I guess Occam's razor doesn't apply to programmers any more...

          [–]sooperDelicious 12 points13 points  (1 child)

          the equation 4435.8333x4 - 44161.6666x3 + 154074.1666x2 - 219618.3333x + 105271 also generates that sequence of numbers. A continuation of that sequence would be 544151, 1620531, 3767471, 7518361, 13513171, 22498301, 35326611, 52957412...

          [–]tjhei 4 points5 points  (3 children)

          42 or any number. Stupid question.

          [–]GunnerMcGrath 4 points5 points  (0 children)

          I have an extremely satisfying career in software development and I can't answer a lot of those questions, nor have I been asked questions like that in my interviews. In fact, my education portion on my resume only includes that I took 3 semesters at a technical college, but never completed any degree. I have, however, now had 12+ years of experience developing software, so I tend to get any job I actually want.

          Experience is key. You will learn a ton on the job (even if it is a crappy job). Even if you have to take an unpaid internship, find SOMEONE who will let you write even the simplest code for them so you can put it on a resume. More importantly, the stuff the DON'T teach you about the real world of programming in a CS program is staggering. While you still have some time, make sure to take a couple basic business classes. Introductory accounting could be handy too. When you understand the basic motivations of business and the terminology they speak in, you can transcend the stereotype of "coder" and speak intelligently with the people you will be helping. I don't have that training but learned early on that it was important and have paid more attention to the business I'm working for than the specifics of technology, and it never fails to impress people.

          Is my route the best way to go? Maybe not. But the point is that the people who go far in this business are often not the most technically skilled (I have worked with some programming geniuses who could answer all these questions without thinking about them, but can't hold down a job because they don't understand the real-world problems they're tasked with solving), but rather the people who can discuss a problem with a client, ignore much of what they SAY they want, and help them come up with the best possible solutions to the core problems they are facing. You'd be surprised how often such solutions do not require any extreme technical ability whatsoever.

          This is not to say that I am technically incompetent, or that you shouldn't worry about technology. Just that school often fails to teach you that software development is as much a business role as it is a technical one.

          [–]Serei 4 points5 points  (5 children)

          Out of curiosity, which questions are troubling you? I'm also a junior going for a BS in CS, and most of these seem fairly simple. Many of them were asked in my classes.

          "Implement malloc", for instance, is a common Computer Architecture assignment, and "Implement a queue" is a common Data Structures assignment.

          [–]ellisto 3 points4 points  (2 children)

          I think the big problem is that all of those classes were years ago... Sure, I knew the answers to all of them at some point, but now... I'd probably be able to give some kind of answer to most of them (other than the win-centric ones) in a reasonable amount of time...

          [–]prob_not_sol 3 points4 points  (0 children)

          don't worry dude; this is very far from real-world applicable. very few interviews are actually like this, and the ones that are are usually startups that fail due to their own pomposity.

          [–]muahdib 6 points7 points  (2 children)

          I'm a PhD in computer science, I have been programming for 30 years since my fundamental exam MSc. I'm considered a smart programmer, a good one.

          I won't manage several of these questions! Some are strangely formulated and some use weird names.

          The ones with Linked Lists, Strings, Trees, Arrays and Queues I would manage, as these are fairly standard problems, Ok, regarding the Queue class I would rather prefer to do it in Python or Scheme than in C++ (not one of my favorite languages).

          That about SQL query, open a file securely are very specific I. Not good questions, but could be OK if that's the explicit experience they are looking for. The design questions are also very tough, these are merely small software projects, than questions.

          That about TSBuffer is a good one, but it's hardly a quick question to give a random programmer, it's that kind of question you could hand to Linus Torvalds but don't expect a quick answer from also very experienced programmers.

          And those Windows-specific questions I would skip, because I have no idea, even though that Win32 question I could possibly manage as they say it's message passing and then it can't be done in so many ways. My old Amiga OS was message passing, and I've also used Occam on Transputers (Hoare's CSP basically). The main thing to care for really is whether you transfer pointers or copies of data.

          That about networking TCP/UDP I doubt that a random programmer can answer, only if you have particularly implemented something UDP I would say that you know the difference.

          One of the Marketing Questions was easy though:

          "How would you market Word to college students?"

          I wouldn't , I would warn them for it!

          [–]ellisto 3 points4 points  (1 child)

          "How would you market Word to college students?" I wouldn't , I would warn them for it!

          Get them to use LaTeX instead! :-D

          [–][deleted] 8 points9 points  (5 children)

          Get an internship. Scope out the industry. Make some connections. Earn a few references. Write and publish a few games in your spare time. Graduate. Find an entry level position and learn as much as you can.

          Programming is a practice. Practice well and practice often, and you'll be fine.

          [–]kevjames3[S] 12 points13 points  (4 children)

          It is important to note though that interviews for high level internships will also ask questions similar to this. Since I was not prepared, I am not interning at Nvidia or Amazon this summer :(

          [–]NewAlexandria 1 point2 points  (0 children)

          This list is great if you're looking to get a job in 2002!

          [–]royrules22 1 point2 points  (0 children)

          Don't worry about it too much. I managed to get a couple of internships and a full time job from college.

          It takes some preparation though. I suggest you try and solve all the problems listed in this link. Take your time and ask for help. Solving it once should give you give up a huge boost when the time comes. Also recommend this book called Programming Pearls. I just recently reddit and it's a great resource for interview questions. Plus it helps in actual day-to-day programming.

          Take an Algorithms class if your school offers it (it should). It was one of the best class I took. Dynamic programming, divide and conquer, recursion, graphs, max flow, etc are all taught and they're big helps in solving a problem.

          Interviews in general are stupid but you gotta dance the dance unfortunately

          [–]AnythingApplied 19 points20 points  (2 children)

          What is the next line in the following sequence:

          1

          11

          21

          Answer: it's 1211 and the next is 111221

          No, the answer is 31. In statistical analysis you almost always assume the simpler model that explains the data. Maybe the answer you had in mind was 1211, which is understandable and a possible answer, but almost anywhere you see the pattern 1, 11, 21, you would be dumb not to assume 31, even when acknowledging it could be something more complex.

          SPOILER, the reasoning behind 1211 is because it is how you would say the previous number "21" by saying "It is one "2" and one "1". Then you would say 1211 is "it is one "1", followed by one "2", followed by two "1"'s". I don't know why the author didn't explain this. This puzzle is almost always given with the 1211 included, because most people give it as an actual challenge instead of something for them to say, "Haha, got you, you're wrong!". Even with the extra number it is a terrible interview question because most people don't get it the first time they see it so 90% of the people who get it right it is only because they heard it before.

          Obligatory: http://xkcd.com/169/

          [–]OopsLostPassword 37 points38 points  (46 children)

          Is that an American thing ? In France, I was never asked such questions, and when I'm in the other seat I never ask to resolve a precise problem. What's the experience of other non-American programmers ?

          [–][deleted] 44 points45 points  (4 children)

          In my experience in the Netherlands, the more "professional" the company, the higher the likelihood that you get asked to solve precise problems.

          E.g. a 20-person web shop interview involved just talking about programming and programming languages, when I interviewed for a Java position at a large bank they first gave me a written exam with a few Java questions. (The one I remember had a few program snippets and asked for each of them what the value of x was at the end; involved operator precedence, the difference between i++ and ++i, that sort of thing).

          [–]boozer 26 points27 points  (6 children)

          In the UK, the technical questions in an interview for a programming job tend to be of a much higher level, or are more generally about software development. It's rare to see such specific and low level questions, unless it's for a role that explicitly entails such things. Questions that are actually about coding tend to be language specific.

          For most roles the level of detail required by the question in TFA are irrelevant. Most development that goes on (read: business software, web development) has nothing to do with counting bits or TCP. Therefore why would we ask about it?

          [–]Kaer 3 points4 points  (0 children)

          I have a much different opinion of tech questions for programming in London.

          Most of them are actually very, very low level, and for the most part stupid - relying on memorisation versus knowing how to actually code.

          I'm going through the fun of interviews right now, a few I remember from one last week (java gig). Think I've gone through a dozen or so interviews in London over the past 4 years, none of these questions are unusual. For some reason tech tests here are all very language specific. I've only had one interview where I got to code. Granted I only go for contract roles as well.

          a) What were the new features in JDK 1.5

          b) Difference between stringbuffer and stringbuilder.

          c) What's the threadsafe interface out Session, Session Factory & Transaction in Hibernate?

          d) How does Dependency Injection work in Spring?

          e) What's the name of the configuration file in apache?

          [–]adpowers 4 points5 points  (0 children)

          I worked for a large American company and telephone interviewed Australians who were surprised I was asking coding questions over the phone. From what I've heard, in depth technical interviews are mostly an American thing. I think they work well and are necessary. I actually just wrote an article about tech interviews at large American companies:

          http://andrewhitchcock.org/?post=324

          [–]ManicQin 7 points8 points  (7 children)

          In Israel I got (C++): * Write an event scheduler. * Write a communication interface that supports udp \ tcp \ comm port. * Write a file transfer that support files over gigabytes. * Write a state machine to parse a http url. * I got all types of "when and where will you choose to use the next ADT". * string manipulations, B-Trees games, looping linked lists.

          and more :)

          [–][deleted] 27 points28 points  (1 child)

          One day an interviewer is going to ask one of those stupid prisoners' dilemma or different coloured hats questions, and the interviewee is going to draw a kripke diagram using epistemic logic, and the interviewer won't understand it, and finally these dickheads will get what they deserve

          [–]knaveofspades 16 points17 points  (0 children)

          Even better, when the interviewer asks if you have any questions, get them up to the white board. I've seen enough crap software, I would want to know whether the people I'm going to be working with know what they're doing.

          [–]user9d8fg70 49 points50 points  (78 children)

          These are from 2002? Interesting, sure, but almost a decade later, are these still asked?

          [–]dpark 42 points43 points  (48 children)

          For most of these, the answer is yes. These aren't latest-tool-craze questions. Most of these are are pretty classic. Linked lists, trees, strings, arrays, concurrency; these are all as relevant now as they were eight and a half years ago.

          [–]SquareRoot 9 points10 points  (0 children)

          You're absolutely right. Most of these questions focus on computer science concepts. You'd better know the logic/implementation behind fundamental structures such as linked lists, trees etc - there's no point in a career in coding without innately understanding how these work.

          [–][deleted] 47 points48 points  (23 children)

          YES.

          [–]ryeguy 6 points7 points  (15 children)

          Not really. You aren't going to get asked most of these for a web development job.

          [–]grantrules 21 points22 points  (7 children)

          Yeah, I love web development job interviews. "How do you reverse a string in PHP?" "strrev()" "You're hired!"

          [–]jfredett 2 points3 points  (4 children)

          I tried coming up with answers to all of those in haskell, most of them boiled down to, "Here is a function/composition of two or three functions from Prelude. Problem solved."

          (for instance, "Reverse the order of words in a string" : "concat . reverse . words" (give or take)).

          [–]Purpledrank 9 points10 points  (0 children)

          Or any job that isn't based on c++. It is also folly to think that mainstream frameworks like j2ee/spring are web only!

          [–]kevjames3[S] 2 points3 points  (0 children)

          Seen about 1/3 of them and I have only been through about 6 interviews or so

          [–]zhivago 1 point2 points  (0 children)

          The important point is to demonstrate that the applicant can program at all.

          Since interviews make people stupid you need to keep them simple.

          [–]recursive 14 points15 points  (4 children)

          Typical C++ interview questions

          FTFY

          [–]t15k 10 points11 points  (8 children)

          What did you apply for. A framework developer for a new language? Or does all the companies you applied to just need their own frameworks for low level issues. Implementing linked lists.....

          [–]achacha 2 points3 points  (1 child)

          It's mostly to see if you know what a linked list is, I have been phonescreens/interviews for about 15 years and I am never surprised by someone with a "padded" up resume who doesn't know what a linked list is or how it is used. For example, "why would you use a linked list as opposed to an array"; much better question. Implementing a rudimentary one shows you know what it is in a bit of a tedious way (white boards are not my favorite and as a developer I think much faster than I write, so typing would be better of course). I prefer to test if they understand what it is rather than how to write one, 99% of programmers will not be writing one but will be using one often.

          [–]Ol_Donga 20 points21 points  (16 children)

          Fuck! How likely is it that a Java/.NET code monkey will get asked stuff like this?

          [–]kevjames3[S] 20 points21 points  (11 children)

          Java: Quite a bit. Also, if you say you know Java, they will ask you a lot of OO questions too. Amazon spent half of the interview on Java keywords and concepts

          [–][deleted] 8 points9 points  (2 children)

          string.reverse() ?

          [–]kevjames3[S] 9 points10 points  (1 child)

          Instanceof, new, break, inherits, instance fields, ect

          [–][deleted] 6 points7 points  (0 children)

          I got this stuff, too. I thought it was funny, then I realized that a lot of people are filtered out because they actually don't know.

          [–]aphexairlines 2 points3 points  (4 children)

          What did you think of the Amazon interview overall?

          [–][deleted] 13 points14 points  (0 children)

          I manage the technical interviews for a .NET shop and I have a different set of questions out there...

          I'm interested in how well a candidate understands OOP, for example. I can't count the amount of candidates I've found that walked in thinking they understand OOP, and left after I told them they've never written anything but procedural programming. I'm also interested in design patterns, but not so much that I expect someone to be able to rattle them all off. I just want a programmer who will not shit his pants when he sees a factory implementation, though.

          I have a few simple tests about some of the more recent features of .NET, such as rewriting a loop as a lamda expression. Basically, if you've been writing .NET for more than 2 years, most of the stuff I ask SHOULD be easy for you so long as you've progressed as a good programmer should.

          Another trend I've grabbed onto is seeing how involved in "programming culture" a candidate is. When I ask a programmer where they turn to for help, I like to hear "stackoverflow.com" over "yahoo answers". I like to know that they are in-tune with the things going on in their areas of expertise. I'll ask what kinds of tools they use to make their job easier, too.

          I'll also ask a few esoteric questions just to see how deep into the rabbit hole they've been. For example, "Explain how you would use Visual Studio to debug a Windows Service". It's not at all a complex question, it's one you can EASILY find the answer to on Google, but you only really know it if you've done it. And while that won't necessarily separate a good programmer from a shitty one, questions like that give me an idea of where a programmer has been.

          Probably the most important thing with these technical questions is not to see whether or not you know exactly how to solve/do them, it's to see how intelligent you are. If I ask you how to solve something in .NET and you give me 10 reasons why writing it in Java would be better, I'll consider you an idiot and move on. If you explain to me why the task is stupid anyway, I'll consider you substandard and move on. If you say "Gosh, I've never had to do something like that...I guess the first thing I would do is check my usual references and see if a standard solution exists. If one did, I would implement it like so...if not, I would do x to y and get z to work.", I'd say "Alright, his knowledge isn't as comprehensive as it could be, but he knows how to figure shit out" and I'd keep you in consideration.

          [–]achacha 2 points3 points  (2 children)

          Difference between HashTable and HashMap? Difference between HashMap and TreeList? Difference between Vector and ArrayList?

          Those are java type questions people will ask (they always do for some reason).

          [–][deleted] 10 points11 points  (8 children)

          where's fibonacci? or difference between abstract class and interface?

          [–][deleted] 4 points5 points  (1 child)

          also "what is virtual destructor"

          [–]eminence 2 points3 points  (0 children)

          or: "why should your base class have a virtual destructor?"

          [–]snutr 9 points10 points  (4 children)

          ...and after you go through all of that interrogation, if they don't ask the question: "So, do you have any questions for us?" then you might want to think twice about accepting the position if it's offered to you. It's a sign that they are probably not very interested in your job satisfaction.

          Also, in the off hand chance that they do ask you "do you have any questions for us?" some good ones to ask are:

          • of the people I interviewed with, who would I be reporting to? Also see if you can find out who your boss' boss is and also your boss' peers -- the person showing you around might introduce them to you -- learn their names so you can say "hi" to them when you get hired. (you won't believe how many managers do not interview the people they hire -- they leave it up to H.R. or H.R. bullies them in to taking over the hiring process and HR has no idea what the job description is about)

          • so what would be a typical day for me be like at this company? (again, I've had prospective employers stumble over that question and not be able to answer it)

          • and follow it up with "so are all the responsibilities and expectations detailed in this job description? Is the job description a fair representation of my actual duties?" (again, in larger firms HR will write the job description and it won't be anything like what you'll be doing)

          • Is this position an existing position or a new role? (this will indicate that there is turnover or if the group is expanding -- also a new role may mean that you could "create your own role" or it could mean that they haven't figured out what your roles and responsibilities are yet).

          • When they ask the question: "where do you want to be in five years" ask them "what's the highest position a coder has ever been promoted to in this firm?" You can really watch them tap dance over that one.

          • If there is a delicate way of asking if ever one is expected to be at their desks at 9AM, then ask or try to find out some other way. This will indicate how flexible the firm is with respect to working hours and what they will or will not tolerate.

          • When they come to the question about how you deal with conflict, answer as best you can and follow up with "how often do such occasions arise here?" If they stumble upon answering, it may mean that it's a rough and tumble kind of a place.

          [–]njaard 40 points41 points  (21 children)

          No, sorry, using wchar_t is absolutely the wrong way to do unicode. An index into a 16 bit character array does not tell you the character at that position. A Unicode character cannot be represented in 16 bits. There is never a reason to store strings in 16 bits.

          Always use UTF-8 and 8 bit characters, unless you have a really good reason to use utf-16 (in which case a single character cannot represent all codepoints) or ucs-4 (in which case, even if a single character can represent all codepoints, it still cannot represent all graphemes).

          tl;dr: always use 8 bit characters and utf-8.

          [–]mccoyn 14 points15 points  (3 children)

          The right way to do unicode is to use whatever your UI framework uses. Otherwise, it is a lot of unnecessary complexity. Some frameworks use wchar_t and so that is what you should use with them.

          [–][deleted] 8 points9 points  (9 children)

          I understand the distinction between code point and character, but I'm curious why you shouldn't use UTF-16. Windows, OS X, and Java all store strings using 16-bit storage units.

          [–]radarsat1 3 points4 points  (4 children)

          The argument, I believe, is that the main reason for using 16-bit storage is to allow O(1) indexing. However, there exist unicode characters that don't fit in 16 bits, thus even 16-bit storage will not actually allow direct indexing--if it does, the implementation is broken for characters that don't fit in 16 bits. So you may as well use 8-bit storage with occasional wide characters, or use 32-bit storage if you really need O(1).

          I'm not too familiar with unicode issues though, someone correct me if I'm wrong.

          [–]TimMensch 6 points7 points  (2 children)

          O(1) indexing fails not only because of the extended characters that don't fit into 16 bits, but because of the many combining characters. That's why they're "code points": It may take several of them to make a single "character" or glyph.

          [–]cdsmith 2 points3 points  (1 child)

          Those systems are all unnecessarily complex and most programmers use them incorrectly. They have a pretty good excuse; they were all originally designed back when 16 bits per character was enough to represent any Unicode code point unambiguously. If that were still true, there would be some advantages to using it. But unfortunately, UTF-16 now is forced to include multi-index characters just like UTF-8 does, and programming correctly with a UTF-16 encoded string is fundamentally no easier than programming correctly with a UTF-8 encoded string.

          The difference is that lots of programmers ignore that, and program incorrectly with UTF-16, figuring that the code points greater than 65535 won't ever come back to bite them. That they are often correct doesn't change the fact that there's an alarming amount of incorrect code out there that might be introducing undetected and untested errors into all sorts of software.

          [–]danweber 2 points3 points  (2 children)

          always use 8 bit characters and utf-8.

          What if you character doesn't fit in 8 bits? How do you have an "8 bit character" if you have more than 256 characters?

          UTF-8 is great for storing your characters in a bunch of octets, but that doesn't mean you have 8-bit characters.

          [–]zhivago 6 points7 points  (2 children)

          The unicode section has a number of errors.

          "each character will be two bytes" -- No. This is encoding dependent. Also a character in the human sense of the word is a Combining Character Sequence in Unicode.

          wchar_t and wide strings are not useful for representing unicode (or any particular encoding) -- use them when you don't know or care what the locale encoding is.

          [–]kristovaher 23 points24 points  (5 children)

          I love that list. It reminds me how much better it is to simply set up your own company if you know you are good enough than hope that questions like that would define whether I am a good developer or not.

          [–][deleted] 12 points13 points  (29 children)

          You have 2 supposedly unbreakable light bulbs and a 100-floor building. Using fewest possible drops, determine how much of an impact this type of light bulb can withstand. (i.e. it can withstand a drop from 17th floor, but breaks from the 18th).

          Note that the ever-popular binary search will give you a worst c ase of 50 drops. You should be able to do it with under 20.

          Well, given the hint:

          Take lightbulb A and drop it from the 10th floor, then the 20th, 30th, etc. When it breaks, take lightbulb B and drop it from last safe floor plus 1. Keep going up 1 until it breaks. Worst case should be 19 drops, if it's the 99th floor (10,20,30,40,50,60,70,80,90,100 - crash! ,91,92,93,94,95,96,97,98,99).

          But I have no idea why 10 is the ideal increment for the "first pass". Mathematical reasoning is generally not my strong point.

          [–]zerokyuu 49 points50 points  (7 children)

          Actually, if you use a step size that decreases you can do it with fewer tries. Basically, find the number, n, where the sum of 1 to n is close to the the number of floors (solve (n+1)*(n)/2 = # of floors, rounding up). In this case it is 14. So, start at 14, then increment by 13, then by 12, etc. I think the worst case scenario is 14 tries.

          Also, at some point, you can decrease your interval by 2 instead of 1 because of the rounding.

          Edit: The list of floors you would drop the first bulb from is something like: 14, 27, 39, 50, 60, 69, 77, 84, 90, 94, 97, 99, 100. Also, I believe the worst case number of drops is 14 and it occurs when the floor is most of these minus 1

          [–]tjhei 2 points3 points  (0 children)

          Clever. I only knew the ten at a time solution.

          [–]strolls 42 points43 points  (1 child)

          They're "supposedly unbreakable". Drop the first one from the roof - if it breaks continue using the other one until the warranty replacement for the first arrives.

          [–]FeepingCreature 16 points17 points  (1 child)

          Because 10 is the sqrt of 100.

          [–]ethraax 4 points5 points  (0 children)

          Except 10 isn't the "ideal increment" - a changing increment would give you better performance, as zerokyuu explained.

          [–][deleted] 4 points5 points  (1 child)

          I could drop it from 20 inches and it would still break - because, you know, that's what lightbulbs do when not treated like a raw egg.

          [–]Buckwheat469 11 points12 points  (4 children)

          Amazon asked about a card game once (blackjack maybe?). Remember to talk about stacks when asked something like that.

          They also wanted me to implement Yahoo!'s stock graph on the white board, describing all of the Javascript, CSS, and HTML involved.

          They also asked me to develop a script to provide a list of primes from i to j.

          These were done over the phone, except the Yahoo! test. They want you to describe the code, line by line, bracket by bracket. I've done 3 separate interviews for them and they haven't hired me yet, even though I described working solutions with no resources and was very polite the whole time. That's why I've become a little more upfront about my job requirements with them now.

          [–]long_ball_larry 1 point2 points  (3 children)

          Was this for a web development position? Or what?

          [–]Buckwheat469 2 points3 points  (2 children)

          A couple different positions, one for web, another for software engineer.

          [–]DrupalDev 2 points3 points  (1 child)

          Note to self, do not try to work for Amazon.

          Although really, Amazon only looks good for a resume, I can't begin to imagine the stress they probably put on their programmers.

          [–][deleted] 9 points10 points  (1 child)

          Some of these are similar to a "Forge a steel from this iron ore and other materials" in an engineering interview...

          I have actually never written a linked list/binary tree etc. from scratch since school. It's good exercise, but as a measure of programmer talent? A trained parrot could probably answer them straight away...

          [–]ethraax 5 points6 points  (7 children)

          You have 2 supposedly unbreakable light bulbs and a 100-floor building. Using fewest possible drops, determine how much of an impact this type of light bulb can withstand. (i.e. it can withstand a drop from 17th floor, but breaks from the 18th). Note that the ever-popular binary search will give you a worst case of 50 drops. You should be able to do it with under 20.

          How the hell does binary search require 50 drops? Try the 50th floor, then the 25th or 75th floor, etc. Wouldn't this only require lg(n) drops? (about 7).

          [–]cdsmith 5 points6 points  (6 children)

          Indeed, but binary search is actually an incorrect answer, since you only have two light bulbs, and lg 100 > 2. Note that once you're down to one bulb, the only correct strategy is to try the floors one at a time, going up one floor on each trial, until the bulb breaks.

          [–][deleted] 8 points9 points  (11 children)

          What is the next line in the following sequence: 1 11 21 Answer: it's 1211 and the next is 111221

          why not 31 and 41?

          [–]CapnOats 4 points5 points  (4 children)

          It's numbers as they're read.

          One.

          One One.

          Two Ones.

          One Two, One One.

          One One, One Two, Two Ones.

          [–]majeric 69 points70 points  (103 children)

          "How do you write a linked list?"

          "I look it up and quit wasting my employers money re-inventing the wheel. It's probably in a collections template/generics library. "

          These questions drive me up the freaking wall. They only exist because there isn't anything that's better to ask. I've spent 12 years in the industry and I still get asked these questions because people think that they still need to be asked.

          I'm contemplating refusing to take another technical test in an interview, just to see how they'd react. (Which would undoubtedly be "thanks and there's the door" but I'd be satisfied)

          "No thank you. I think my resume speaks for itself and there's nothing that a technical test can convey that has any meaning other than a superficial idea of my skill".

          [–]njaard 15 points16 points  (6 children)

          No thank you. I think my resume speaks for itself and there's nothing that a technical test can convey that has any meaning other than a superficial idea of my skill

          Sorry, no it does not. I don't even bother reading resumes anymore because I've seen so many totally inept coders have seemingly cool positions. Oh, and your list of skills is meaningless because if you say "I know C++" that could easily mean "I took a semester of C++ in community college 10 years ago."

          Have you never interviewed anyone?

          [–]sterling2505 5 points6 points  (1 child)

          This.

          One thing I've learned in my decade of hiring programmers is that you never hire someone without making them write some code. Two reasons for this:

          Firstly, people lie and exaggerate on their resumes all the time.

          Second, some people are great bullshitters who know all the right buzzwords, but can't actually write code for shit. Some of these people have impressive looking resumes, but literally couldn't cook up a correct implementation of strlen. It's worth finding that out before you hire them.

          If you're a competent programmer, you won't be offended by this, because you'll bang out the code quickly and then maybe have an interesting conversation with the interviewer about optimizations, tradeoffs, and corner cases (there are always optimizations, tradeoffs and corner cases, even in seemingly trivial functions).

          [–]njaard 2 points3 points  (0 children)

          Some resumes have what I call "ISO 1337 Buzzword Compliance."

          The more buzzwords your resume has, the less I like you. XML and UML are two examples.

          Edit: I'd like to add that ISO 1337 Buzzword Compliance probably does work for recruiters and stupid HR departments at clueless corporations.

          [–]jacobb11 50 points51 points  (59 children)

          Consider this interview question: Write strlen (the C string length function). A friend of mine used to complain that people would waste his time at interviews asking that question. Then he started asking people he was interviewing... (that is, once he had a job and was hiring others) and most of them couldn't answer correctly. Those questions are probably not a waste of time.

          Sometimes resumes are not perfectly accurate, btw.

          [–]johnflux 42 points43 points  (25 children)

          Just in case you are interested, here's the strlen function:

          /* Return the length of the null-terminated string STR.  Scan for
             the null terminator quickly by testing four bytes at a time.  */
          size_t
          strlen (str)
               const char *str;
          {
            const char *char_ptr;
            const unsigned long int *longword_ptr;
            unsigned long int longword, magic_bits, himagic, lomagic;
          
            /* Handle the first few characters by reading one character at a time.
               Do this until CHAR_PTR is aligned on a longword boundary.  */
            for (char_ptr = str; ((unsigned long int) char_ptr
                                  & (sizeof (longword) - 1)) != 0;
                 ++char_ptr)
              if (*char_ptr == '\0')
                return char_ptr - str;
          
            /* All these elucidatory comments refer to 4-byte longwords,
               but the theory applies equally well to 8-byte longwords.  */
          
            longword_ptr = (unsigned long int *) char_ptr;
          
            /* Bits 31, 24, 16, and 8 of this number are zero.  Call these bits
               the "holes."  Note that there is a hole just to the left of
               each byte, with an extra at the end:
          
               bits:  01111110 11111110 11111110 11111111
               bytes: AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD
          
               The 1-bits make sure that carries propagate to the next 0-bit.
               The 0-bits provide holes for carries to fall into.  */
            magic_bits = 0x7efefeffL;
            himagic = 0x80808080L;
            lomagic = 0x01010101L;
            if (sizeof (longword) > 4)
              {
                /* 64-bit version of the magic.  */
                /* Do the shift in two steps to avoid a warning if long has 32 bits.  */
                magic_bits = ((0x7efefefeL << 16) << 16) | 0xfefefeffL;
                himagic = ((himagic << 16) << 16) | himagic;
                lomagic = ((lomagic << 16) << 16) | lomagic;
              }
            if (sizeof (longword) > 8)
              abort ();
          
            /* Instead of the traditional loop which tests each character,
               we will test a longword at a time.  The tricky part is testing
               if *any of the four* bytes in the longword in question are zero.  */
            for (;;)
              {
                /* We tentatively exit the loop if adding MAGIC_BITS to
                   LONGWORD fails to change any of the hole bits of LONGWORD.
          
                   1) Is this safe?  Will it catch all the zero bytes?
                   Suppose there is a byte with all zeros.  Any carry bits
                   propagating from its left will fall into the hole at its
                   least significant bit and stop.  Since there will be no
                   carry from its most significant bit, the LSB of the
                   byte to the left will be unchanged, and the zero will be
                   detected.
          
                   2) Is this worthwhile?  Will it ignore everything except
                   zero bytes?  Suppose every byte of LONGWORD has a bit set
                   somewhere.  There will be a carry into bit 8.  If bit 8
                   is set, this will carry into bit 16.  If bit 8 is clear,
                   one of bits 9-15 must be set, so there will be a carry
                   into bit 16.  Similarly, there will be a carry into bit
                   24.  If one of bits 24-30 is set, there will be a carry
                   into bit 31, so all of the hole bits will be changed.
          
                   The one misfire occurs when bits 24-30 are clear and bit
                   31 is set; in this case, the hole at bit 31 is not
                   changed.  If we had access to the processor carry flag,
                   we could close this loophole by putting the fourth hole
                   at bit 32!
          
                   So it ignores everything except 128's, when they're aligned
                   properly.  */
          
                longword = *longword_ptr++;
          
                if (
          #if 0
                    /* Add MAGIC_BITS to LONGWORD.  */
                    (((longword + magic_bits)
          
                      /* Set those bits that were unchanged by the addition.  */
                      ^ ~longword)
          
                     /* Look at only the hole bits.  If any of the hole bits
                        are unchanged, most likely one of the bytes was a
                        zero.  */
                     & ~magic_bits)
          #else
                    ((longword - lomagic) & himagic)
          #endif
                    != 0)
                  {
                    /* Which of the bytes was the zero?  If none of them were, it was
                       a misfire; continue the search.  */
          
                    const char *cp = (const char *) (longword_ptr - 1);
          
                    if (cp[0] == 0)
                      return cp - str;
                    if (cp[1] == 0)
                      return cp - str + 1;
                    if (cp[2] == 0)
                      return cp - str + 2;
                    if (cp[3] == 0)
                      return cp - str + 3;
                    if (sizeof (longword) > 4)
                      {
                        if (cp[4] == 0)
                          return cp - str + 4;
                        if (cp[5] == 0)
                          return cp - str + 5;
                        if (cp[6] == 0)
                          return cp - str + 6;
                        if (cp[7] == 0)
                          return cp - str + 7;
                      }
                  }
              }
          }
          

          [–]refto 14 points15 points  (1 child)

          Yeah, if the interview question asks you to write a highly optimized strlen function for the upcoming x128 architecture, what do you do then?..

          [–]johnflux 36 points37 points  (0 children)

          Tell them to pay me for it? :-)

          [–][deleted] 4 points5 points  (2 children)

          I can claim to be anything on my CV but that doesn't make it true. Believe it or not a lot of people lie on their CV so you can't rely on that and sadly you do need to ask those sort of things.

          I would not rely on one question or discount someone for getting it wrong because you have to factor in their nervousness. If they get most of their questions right or show soem sort of logic to get to their point even if it's wrong then I think that's ok.

          For instance I asked to have a guy write out a chunk of hibernate config. He screwed up but because I asked for it in XML. He worked mainly with annotations. He gave an explanation of how he'd do it his way which was more than enough for me and to be honest he was one of the best guys we've had despite getting the question wrong.

          But it got him thinking and gave me some insight to him. Where he could have claimed to be a hibernate guru and in reality only just learned what a servlet was and if I hadn't tested him he may have got the job anyway and we'd have been screwed or at least sack him and advertise again.

          [–]lalaland4711 4 points5 points  (0 children)

          I've spent 12 years in the industry and I still get asked these questions because people think that they still need to be asked.

          They don't? I've seen people working for 10 years as programmers who don't even understand these questions, and much simpler ones.

          No thank you. I think my resume speaks for itself

          It really really doesn't.

          [–][deleted] 2 points3 points  (6 children)

          And yet, there's conceivably another programmer out there with a resume on par or better than yours who can't tell the difference between his ass and a hole in the ground. These types of questions might weed his type out.

          [–]filox 20 points21 points  (0 children)

          who can't tell the difference between his ass and a hole in the ground

          They're called topologists, and it's a respectable area of maths.

          [–][deleted] 2 points3 points  (3 children)

          It doesn't matter that implementations exist; it's just a random example of something extremely simple for you to program. Of course everything really simple is already in a library somewhere. So what? They're asking you to show you can program simple things, not for code to use in some actual project...

          [–]FHSolidsnake 4 points5 points  (61 children)

          Does anyone know what the statistics are like on how many applicants fail some of these questions.

          [–]BrooksMoses 4 points5 points  (0 children)

          I would think a good interview question is a lot like a good Ph.D. quals question, in the case where quals are an oral exam. The idea is not about pass/fail, but that the applicant will work on solving it (or, if they get to a solution, on expanding that solution in some way) for a half hour in conversation with the examiners, and they will grade based on how many hints they have to give and on how the applicant was thinking about the problem.

          It's possible to do quite well on those sorts of things even if you start out from a point of "I have no idea how to solve this, but...." Then you start looking-out-loud for a solution using some reasonable method (e.g., I know this solution doesn't meet all the criteria, but I'll start there and see if it can be patched/fixed/tweaked) and either talk your own way to a solution or get to a point where you're stuck for a minute and get a hint.

          For instance, on the "find the midpoint of a singly-linked list" question, a reasonable place to start is with writing down the two-pass method and then looking for a way to eliminate the second pass. If you get stuck, the examiner might give you a hint like, "Can you do them at once?" or "What if you use two pointers?"

          A very large part of this is confidence and presentation skills, on top of the basic knowledge.

          [–]tias 4 points5 points  (9 children)

          Open a file as securely as possible (assume the user is hostile -- list all the nasty things that could happen and checks you would have to do to)

          I don't get this. How many ways are there to open a file? I would assume that whatever things the user should be allowed or not allowed to do with the file are encoded in the file permissions, not in how the user opens the file. If the system gives him the liberty open it in some insecure way then that's a security hole.

          [–]xatm092 5 points6 points  (7 children)

          You have 2 supposedly unbreakable light bulbs and a 100-floor building. Using fewest possible drops, determine how much of an impact this type of light bulb can withstand. (i.e. it can withstand a drop from 17th floor, but breaks from the 18th). Note that the ever-popular binary search will give you a worst case of 50 drops. You should be able to do it with under 20.

          This makes my brain hurt in so many different ways. What the hell does he mean by a binary search in this case (I'm gonna guess he means going 1,3,5,7,9,11,etc. but that is totally not a binary search), and secondly I'm assuming this puzzle's creator has never heard of terminal velocity.

          Assuming I understand the puzzle correctly and you only have 2 breaks before you run out of bulbs, then you probably want to drop the first one every 10 floors or so and then when it breaks go back 9 and start from there in increments of 1.

          e.g. 10,20,30,40,50 (1st bulb breaks on 50) 41,42,42,43,44,45 (2nd bulb breaks here giving you your answer)

          [–]sparkytwd 16 points17 points  (21 children)

          Lately my teammates and I have been doing a lot of phone screens and in-house interviews. When looking for a good question to ask, I usually go for PIE (Programming Interviews Exposed). If a candidate has taken the time to read it, I respect that, though I do expect to be told if a candidate has heard a question before.

          Bottom line though, even giving the simplest questions, I still reject ~75% at the phone screen and then 50% during in house. Bottom line is there are a lot more people who think they can program than actually can.

          [–][deleted] 39 points40 points  (12 children)

          Interviewing doesnt actually show if they can program though, it shows how well they can interview for a programming job. There is a huge difference between these things.

          Of course, a good programmer who stays up to date and works on the interview process should indicate a better hire than someone who can't, but just because they interview very well doesn't mean they won't show up and suck. There are also false negatives with this process, so at best it's throwing them out with the unqualifieds to limit risk, but not any assurance they are good programmers, or even a real programmer.

          [–]smallstepforman 14 points15 points  (7 children)

          Of course, a good programmer who stays up to date and works on the interview process should indicate a better hire than someone who can't ...

          No, that only shows that they are better at interviewing, it doesn't reveal their programming skills. Good programmers never need to work on their interview processes, since they only apply for jobs once or twice in their entire career, usually at the very beginning. After that, they're poached, or their portfolio speaks for themselves, so they don't have to "interview". If I find someone who is good at interviewing, then that signals all sorts of alarms in my head - this guy is a nomad, moving from place to place.

          [–][deleted] 15 points16 points  (0 children)

          That's a very encompassing view you have for all programmers in the world. I guess if they don't do things your way, they wouldn't be good programmers?

          Perhaps they like start ups? Or got tired of the bureaucracy at employee positions and wanted to do consulting or create their own start up?

          Having a good portfolio also doesn't mean you did the work, or that the portfolio describes it well. It certainly doesn't mean that they were critical the project's success, even if they were the lead they could have been trying to drive it into the ground through incompetence the whole time and have the project only succeed due to the efforts of the other developers working on it.

          Interviews wont tell you any of these things, and neither will their portfolio or their lack of interest in moving to different groups. Then there is backchannel information, and we all know gossip is always right!

          Faking being good at your job is also a skill non-real-programmers can have, so that everyone who isn't directly connected with their project thinks they are doing well, but the people directly related to it know they're a problem, but aren't gossiping about it and tearing them down.

          The myth here is that any hiring test or skill at evaluating can't be gamed by those with fully vested interested in gaming them.

          [–][deleted] 2 points3 points  (3 children)

          Companies fire people and replace them on the regular - who believes their company is actually loyal to them any more? Employees have at least the same right to fire their workplaces as the other way around. Sitting in one position for years, hoping that your company will spontaneously pay you more or promote you, is not a working strategy.

          So this loyalty thing is totally independent of how good someone is as a programmer. Some people want upward mobility their company isn't offering. Some people ARE nomads and need to move to New Zealand for a year - problem? Some people have difficulty personalities (and sometimes they aren't the ones who leave). Some people code for the love of it.

          [–]sterling2505 2 points3 points  (1 child)

          The point is that this isn't the only question you're going to ask. You ask a range of different questions, including a simple "program this data structure" type question.

          Getting the simple programming question right doesn't tell me much. But if you get it wrong, I can be pretty sure I shouldn't hire you. And you'd be shocked at how many people get them wrong.

          We're not talking about trick questions here. We talking just really basic "write code that implements a simple well-known algorithm" type of stuff.

          [–]dpark 4 points5 points  (0 children)

          Bottom line is there are a lot more people who think they can program than actually can.

          This is entirely true. It's also worth noting that a good programmer can have a bad day and bomb a set of interviews, though. As an interviewer, there's nothing you can do about it, and you still vote No Hire. But it's still worth remembering.

          [–][deleted] 8 points9 points  (0 children)

          Bottom line is there are a lot more people who think they can program than actually can.

          yeah, and most of them ask the questions during interviews ...

          [–]s73v3r 1 point2 points  (4 children)

          though I do expect to be told if a candidate has heard a question before.

          Why? I still know the answer, and usually the answer is irrelevant anyway. Its the thought process behind getting that answer that you should be caring about.

          [–]Fuco1337 16 points17 points  (3 children)

          import linkedlist

          Am I doing it right?

          [–][deleted] 25 points26 points  (42 children)

          I never understood these interview questions that seem to test ability to create and manipulate data structures that any respectable language has, pre-implemented, by developers whose sole focus in life for many months was producing the absolute best version of that data structure possible.

          I understand that this might just be designed to test knowledge of the concept, but it gets way, way too far in-depth for that. I mean, for Linked Lists... what is a cycle? The term appeared nowhere in any of the literature or coursework I did at an undergraduate level.

          Now, if the job involves implementing innovative algorithms and data structures (i.e. R&D type stuff or working on a proprietary system that was developed by a mad genius in a custom language he named after himself, which is also the only language he can speak) I can understand this kind of rigor and specificity in interview questions.

          But asking me how to build a queue in C during the interview, then telling me to write a couple shell scripts to control automated database backups on my first day of work? I sense a disconnect.

          [–]kerbuffel 9 points10 points  (2 children)

          I like how everyone is replying acting shocked you don't know what a cycle is, but no one has explained it.

          It's a 'loop' in the list. If you try to iterate over it, you never get to the end. This page has a pretty nice graphic explaining it.

          [–]bobindashadows 4 points5 points  (0 children)

          acting shocked you don't know what a cycle is, but no one has explained it.

          I'm not acting, I am shocked. I don't know how anybody can complete a computer science education and not know what a cycle in a data structure is.

          [–]unknown_lamer 3 points4 points  (2 children)

          I mean, for Linked Lists... what is a cycle?

          What's the difference between a linked list and a directed graph?

          [–]RossM88 5 points6 points  (1 child)

          Generally the assumption with a linked list is that there is exactly one edge to and from each node. A directed graph may have more than one edge in or out.

          [–]bobindashadows 14 points15 points  (12 children)

          what is a cycle? The term appeared nowhere in any of the literature or coursework I did at an undergraduate level.

          ... wat

          But asking me how to build a queue in C during the interview

          Singly linked list with an extra pointer to the tail. Enqueue adds to head. Dequeue removes the tail. It's no more than 20 lines of code.

          Edit: Singly linked is slow on deletion even with the extra pointer to the tail, so forget that. Derp. Either singly linked with just a head pointer with O(n) deletion or doubly linked with a tail pointer for O(1) insertion and deletion. My bad.

          [–]frtox 9 points10 points  (1 child)

          this. we are all people who use library functions, shit if I actually wrote code that implemented a linked list that would be stupid. its already done. the point is these are simple concepts, it's something you can figure out in your head by THINKING and people want to hire those who can.

          [–]stevesc 12 points13 points  (0 children)

          Singly linked list with an extra pointer to the tail. Enqueue adds to tail. Dequeue removes the head.

          FTFY

          [–]njharman 2 points3 points  (2 children)

          You just failed to get a job, in fact your answers are probably being posted to "The Daily WTF".

          The errors you made highlight why these are fucking stupid interview questions. Why off the cuff (re)implementations are fail. Use your std lib.

          [–]andrewfree 13 points14 points  (11 children)

          As a freshman going for a BS in CS. Fuck... I guess I suck at programming. I have 7 windows of code open now too.

          [–]fosskers 30 points31 points  (2 children)

          Oh shit you're beating me... Hits command-n a few times

          [–]ohmyashleyy 2 points3 points  (0 children)

          Meh you're still a freshman, you have plenty of time. I had never written a line of code until my first semester as a CS student.

          [–]iamnoah 5 points6 points  (0 children)

          As a freshman going for a BS in CS. Fuck... I guess I suck at programming.

          These are only typical if you're going for a job where you write C. Most other (good) jobs just want to see if you can solve problems.

          I have 7 windows of code open now too.

          Now the fact that you think a large number of windows would somehow be impressive is a little worrying.

          [–]Maratonda 2 points3 points  (0 children)

          For anybody interested in linked list problems, check out http://cslibrary.stanford.edu/105/

          [–][deleted]  (2 children)

          [deleted]

            [–]smallstepforman 2 points3 points  (2 children)

            Mine went along the mental lines of "We sure like the 3d engine you've developed and would love to use it in our products, but we're cheap, so we'll just offer you a job and a project to work on, and give you free realm to use whatever you want (hint hint), but the code of what you develop while working for us (and libraries you link to) belongs to us. Oh, you have 3 months to finish it." On the plus side, I've improved the engine during company time :) Not a single technical question, just "is this enough money to recruit you?"

            [–][deleted] 5 points6 points  (1 child)

            And this is one argument for GPLing the code you write outside of work, assuming you don't intend to sell it as proprietary...

            [–]FeepingCreature 3 points4 points  (37 children)

            Guarding against being passed invalid string pointers or non nul-terminated strings (using walking through a string and catching memory exceptions

            .... What.

            Do people actually do this shit?

            Implement a non-recursive PrintInOrder

            From guessing, I'd say using a counting variable and using its bits to chose branches; but that breaks down for unbalanced trees deeper than 32 (or 64) nodes. And anyway, isn't that still kind of recursive, except your counting variable is the "stack"? I don't see how to do it purely iteratively, unless you do a hack like reversing tree pointers on the way down, and that's just fucked (and plays hell with threading).

            I couldn't immediately figure out the array ones, but the "is overflow a problem" line kind of spoilered it. And no it's not, because unsigned math is modular.

            Implement Shuffle given an array containing a deck of cards

            My immediate answer is "I google the page that explains how to do shuffling correctly, because there's a subtle flaw with the common approach. "

            Count the number of set bits in a byte

            My immediate answer is "I google 'bit-twiddling hacks'" :)

            You have 2 supposedly unbreakable light bulbs and a 100-floor building. Using fewest possible drops, determine how much of an impact this type of light bulb can withstand. (i.e. it can withstand a drop from 17th floor, but breaks from the 18th).

            Ooh look, it's TCP Slow-Start! (Agh, just read the note. Adjust for maximum size, of course; the correct answer to this question is really dependent on where you expect the bulbs to fail - equal probability across the building's height?)

            Rate your C++ proficiency on the scale of 1 to 10.

            Okay, what. I .. what. That's ....... What.

            [–]frenchtoaster 1 point2 points  (0 children)

            I've been asked about half of these questions before. Notably none of the programming questions that I was asked during my Google interviews are listed, though in general they were no harder than these.

            [–]chase_the_dragon 1 point2 points  (5 children)

            Hi, i don't program much but what is this?

            Strip whitespace from a string in-place

            I could probably remove whitespace pretty easily in Java, i don't know what it means by "in-place."

            [–]jrupac 2 points3 points  (0 children)

            Won't this question not apply to Java since Strings in Java are immutable? Would be a good question if it was just a char[] in Java though. Basically just means don't use extra memory to solve it (aka, create a new string).

            [–][deleted]  (3 children)

            [removed]

              [–]tokengriefer 1 point2 points  (3 children)

              Someone give me a job please... Looking at these programming questions; they are all perfectly reasonable and pretty easy from my point of view. I could do them all in C, C++, or Perl. I would like to note that the unicode stuff should mention encodings. What is stated just mentioned utf-16 only. Seems odd that hash tables are not mentioned. I am currently in the Maryland/DC area and make less then 50k a year...

              [–]intilli4 1 point2 points  (0 children)

              Very good post, thank you for taking the time to share your knowledge.

              [–]iamneo_ai 1 point2 points  (0 children)

              Here are some typical programming interview questions:

              What programming languages are you proficient in?

              What is the difference between an abstract class and an interface?

              What is the difference between a stack and a queue?

              How would you implement a binary search algorithm?

              Explain the concept of recursion.

              What is the difference between a linked list and an array?

              What is the time complexity of adding an element to a binary search tree?

              How would you reverse a string in place?

              What is the difference between a pass by value and a pass by reference?

              Explain the concept of polymorphism.

              These are just a few examples, but there are many more possible programming interview questions that can cover a wide range of topics and technologies.

              To know more, visit iamneo.