3 ms·
Having just spent half an hour to figure out (3) by swapping letters around, I think (1) may still be easier even in C because the method is straightforward. Ar
by jules 16y ago
Having just spent half an hour to figure out (3) by swapping letters around, I think (1) may still be easier even in C because the method is straightforward. Are you using functional languages where you work? Interviewees who use a language with list comprehensions would have a significantly easier time with this question (the solution being two lines of code instead of 10+ lines of intricate letter swapping).
Did any of the candidates use Python or ML or Haskell? What is the reason they didn't get it right?
It may be harder to figure out idea of the algorithm than the implementation details, but in my experience you often won't even think about the high level algorithm if you are in a C++ mindset, you'll only think about swapping letters around.
- dkarl 16y agoNobody chose Python, ML, or Haskell. Some chose Perl, which I took as a promising sign, but they didn't do any better than the ones who chose C++ or Java. Actually conceiving of the solution was the roadblock for most, but the ones who got past that struggled to figure out the recursion -- what should be the signature of the recursive function?
- jules 16y agoThey couldn't even figure out the type of a function that takes a string and returns a list of permutations? That is...unexpected. One wonders how so much working software gets written.