Quote:
Originally Posted by gaming_mouse
i'd give the direction to clean the code up as much possible and give me an example of what you consider clean, production quality code.
Quote:
Originally Posted by gaming_mouse
indeed, and someone who choosing one of those convoluted ways (and not realizing there are simpler ones) is valuable information about them. i mean, it's not like the simpler solutions here are difficult "tricks" that it would be unfair to expect someone to find.
This does not follow. One of the ways in which "production quality" code differs from you know, random answers to interview questions is that it may trade simplicity for extensibility or other attributes. Also by this definition, using "sort" is convoluted. Why is it any more convoluted to rely on a different general algorithm, especially if the candidate offers to implement it? Because sort is included in the standard library?
If you give an interview question, the candidate provides a solution and you go, oh I don't understand how you solved it, can you re-solve it, you know, this other specific way that I like to solve the problem, that's an easy way to lose credibility with some of the very best candidates. If you're a young technical person interviewing another young technical person, you're almost certainly being judged in return and giving a problem that can easily be extended in ways you don't comprehend is a very quick way to fail the reverse interview.
Again, this isn't a great reason not to ask questions that are otherwise good, but this question is completely trivial and what you're trying to measure with this question is entirely trivial. This interview question itself is a convoluted answer to a trivial, solved problem. Reverse a string, Nth from the end on a linked list, fibonacci, etc, etc - there's no shortage of interview questions that are at this level of complexity and avoid the pitfall. As a bonus, most of these questions also give you a better spectrum of answers - how fast you solve these problems is going to give you information whereas how fast you solve a weird cartesian coordinates problem is going to give you very little, because you don't know how that time was spent.