I’m going to begin posting weekly a technical interview question. Generally, each question should be solvable in less than 30 minutes time. Often, much less. Some amount of coding is typically necessary to solve the problem (either actual code or pseudo-code), but occasionally, just a plan or discussion-style response is expected.
I’d consider these questions to be of the Microsoft technical interview style questions (having worked there, I both was interviewed and interviewed others, so I have some experience with them). If nothing else, you might find them interesting problems to think about for a couple of moments during your day. That’s my primary reason for posting them: a little brain teaser during your day.
I’d really like to see who can answer them first, BUT, given the nature of the Internet and time zones — it’s not really practical. If you have an answer that you’d like to show off and you have a blog, put the answer on your blog, and link to the question and post a comment (if trackbacks aren’t working). Otherwise, feel free to post the answer in the comment. There often will be more than one answer!
Code it in any language you’re comfortable with! There’s no right or wrong language for these questions (unlike many interviews at Microsoft that have historically considered C/C++ the "only" language you should use).
By the way, a long answer isn’t necessarily a "wrong" answer, but it’s probably not the best answer. :)
(I’ll go as long as I can with the series … if you have questions you’d like to see added, feel free to contact me using the contact form in the header, or send an e-mail to coder at this website).