3 coding puzzles 100% of a middle school class got, versus 50% of interviewees

Skip down to the end if you just want interview prep suggestions.

There’s a lot of debate as to whether algorithms interview questions are effective.  However, sometimes coding questions provide a good filter. In our case:

  • These questions were “CS101” level
  • We believe a good developer needs to be able to make good decisions, and good decisions rest on a deep understanding of how many complex systems interact. If a developer can’t reverse a string, how could they possibly understand the performance implications of large client facing software?

Admittedly, the middle school students in our CS02 course are quite bright (one has placed in the USA Computing Olympiad). However, after several years of interviewing for the big software companies (Microsoft, Amazon, Google) — professional developers don’t perform much better than our career counseling clients.

The questions:

1. Sum up numbers from 10 to 100 that are multiple of 3 or 5

Run this Java solution in your browser:

2. Reverse a String without using a reverse function (and only language docs)

Run this Java solution in your browser:

3. Reverse a Stack

Run this Java solution in your browser:

The problem solving steps and failures:

  1. Parse the English and do the problem by hand
    • This step was harder for kids than for adults.
    • However, if students who misread the problem were told to re-read it, kids out performed adults.
  2. Come up with a pseudo code algorithm
    • Students did somewhat better than adults on this step.
    • Shockingly, many adults did not know how to extract a character out of a string in their preferred language
  3. Convert the algorithm into code
    • Shockingly, many adults did not know how to extract a character out of a string in their preferred language (not just any language)
      • We had C++ programmers who would not know about square brackets, and C programmers who start with pointer arithmetic but fail
    • Even more shockingly, many adults could not find appropriate documentation to solve their problem when allowed to search the API docs (Java) or use a book reference.
    • Yes, some middle school students had forgotten how to use a stack or instantiate a Queue. However, all were able to look up how to do it within the appropriate time.
    • Adults who *were* able to write code often fell out of the time limits.

There is a glut in bad coders, but do not fear if you are one of them

The solution is not for job hunters to attend a “full stack bootcamp”. Instead, if you’re an adult who struggles with coding puzzles:

  1. Practice until you can quickly write small snippets without errors. There is no excuse for not being able to write a double loop in your favorite language. Find a coding quiz with examples you can read and understand in less than a minute. Do hundreds of these type of problems. (not just dozens, really!)
  2. Write a list of use cases for every “textbook” algorithm. One common mistake is to merely memorize a table of computational complexities. However, seeing examples of where, say, A* search is used goes a lot longer way than even studying the code itself.
  3. Do at least one large project that forces you to use job relevant APIs / use cases. The language often does not matter, and writing a large project on your own forces you to learn new design patterns and step away from legacy code maintenance. Coding interviews are intelligence tests, so they are rarely focused on  a specific architecture.
  4. Expose yourself to better programmers. With the huge growth in computing or CS jobs, the current solution to the market for lemons is the coding interview. However, there is a lot of other signalling that occurs. For example, knowledge of trendy topics, blogs, technologies can signal “awareness” of “important” issues. Likewise, humorous coding horror stories can signal experience and the ability to tackle new problems. Lucky, online coding communities are a dime a dozen, so the only hurdle is time and humility.

Good luck coding! Try our Java intro and CS00 tutorials.

2 Replies to “3 coding puzzles 100% of a middle school class got, versus 50% of interviewees

  1. Hi!

    Not a native English speaker, but I’ve always understood “either … or …” to mean an exclusive or, in which case your solution one is wrong since it’s also including the numbers divisible by both 3 and 5.

    Now if Java only had an operator for logical exclusive or…

Leave a Reply

Your email address will not be published. Required fields are marked *