Sunday, July 14, 2013

LINQ Ruined My Favorite Interview Question

    Recently I was interviewing candidates for some positions we had open.  When I look at lots of candidates back to back I like to use the same interview question so I can compare their answers against each other.  Over the years there is one technical coding question I've been going to more often than others as its fairly easy to describe the problem and there is just enough complexity that a good candidate can code it while leaving time for probing the depth of their understanding.  The question is "Return the top 10 most frequently occurring words in a string."  This year a couple candidates gave me a solution which I haven't seen in 5+ years of asking this question—they solved it with a couple lines of LINQ.   I decided to dig deeper in to these solutions post interview and I'm writing up what I learned.

It's not really correct to say that my question was ruined … as with any interview question I want to understand the candidates thought process and how much they understand the ins and outs of their solution.  But the solutions did catch me off guard.  Even though I use C# fairly regularly over the last decade I never updated my knowledge when LINQ was added.  What I wanted to do now was first learn a bit more about these solutions and compare them to solutions which didn't use LINQ. 

Read more: Scott Chamberlin
QR: Inline image 1