Three years ago, I got into an interview into a company that was looking to hire a .NET developer for the first time. It was mainly a Java software house and, until that point, they have not had a requirement that called for a developer who mainly worked on the Microsoft stack.
Having had worked on .NET for a year and a half with both Windows forms and ASP.NET development up my sleeve, I was pretty confident that I knew enough to be able to get the job. That is, until the interviewer presented me with a problem that appeared pretty basic at the onset: write a function that would get the factorial of a given positive integer.
I wrote mine with an ordinary for loop. I was pretty sure it worked. Until the interviewer continued.
"Now rewrite that using recursion."
I froze. "What?"
"Use recursion." And right then and there I didn't know what to do. Now, some of you might think that recursion is so elementary that anybody with the amount of experience I had at the time would've known it, but obviously, I did not. I hadn't graduated with a Computer Science or Computer Engineering or Software Engineering degree: I was mainly a hobby developer until I took it seriously and tried my hand at the software development industry.
I was able to muddle through with most of it (thanks to Google for the most part) but until that day, I hadn't heard of what later appeared to me as a very basic software development concept. I was floored.
Fast forward to last week. This time I was trying out for a position with Microsoft itself; there were openings for their Shanghai and Copenhagen offices, and a hiring team from Redmond was sent to Manila. I easily passed the first two screening interviews, so I was pretty sure I'd make it to the last one.
In came the first interviewer with the first question: find if a given string is a palindrome, e.g., it's the same spelling whether spelled forwards or backwards. So I gave the following answer:
- public bool IsPalindrome(string s)
- return String.Reverse(s) == s;
Guess what: that answer is wrong. I tried to find out why, but my interviewer didn't care to expound and showed me the door.
Ironically, on the evening of that interview, Stack Overflow Podcast 23 came out and Joel Spolsky tells a story of how he was shocked to find out that using strlen() to find the length of a string degrades the algorithmic performance of a certain piece of code, when his code was reviewed by a senior developer. Turns out I had precisely the same problem: reversing the string adds to the complexity of my solution because it needed to traverse the whole string again. For a few thousand characters it would be perfectly fine, but for a string with millions or trillions of characters (e.g., a DNA sequence) it would've been very, very slow.
And I didn't know that considering that I've been on the industry for six years already.
Despite not getting the offer, I am nonetheless thankful for being able to experience a Microsoft interview. It merely affirms the lesson I learned back in the "recursion" interview: interviews are a great way to assess your abilities, and to find out what else you need to learn.
In a profession that thrives on learning new things, this information is quite invaluable.