I’ve been using an easier version of my coding question lately, because candidates have struggled so much. First I moved it from C to C# (or Java, if candidates only have a java background). Then I simplified it, a lot. The problem is simple: reverse a string using no outside libraries. This was an introductory-level when I interviewed at Microsoft but now it seems to be advanced!
I’ve had candidates waste 40, 50 lines of code answering this. They usually don’t answer the question at all (they won’t write the full function with signature, or they reverse any words w/o reversing the characters, etc.).
I tried it again last night against .NET 3.x—I wanted to make sure I wasn’t expecting too much--you know, maybe programming has changed while I’ve been in meetings! ;).
I ended up with a small challenge (converting my char[] so it returned a string—kept returning the object type), but other than that, this went really well. 15 lines of code, including curly braces and the step to convert from the input string into a char[] (no error handling; have to get to that next)
Is the question too difficult? Wanna take a stab? Can you beat 15 lines, without using string.Reverse()?
Hi John. Assuming you're attempting to hire programmers, what you're asking is not that difficult. Here's a 10-line Java version (sorry I didn't have C# installed):
ReplyDeletepublic String reverse(String s)
{
assert(s != null);
StringBuffer buf = new StringBuffer();
for (int i = s.length() - 1; i>=0; --i)
{
buf.append(s.charAt(i));
}
return buf.toString();
}
It's commonly known that there can easily be differences of 10x in programmer speed / effectiveness, as a Google search for "programmer productivity 10" shows. If a programmer can't handle that request in a couple of minutes, you probably don't want them programming for you.
At first glance my code above might seem fine, but in reality, it's not. Certain Unicode grapheme's can't fit into a single character (even though Java's char is 32-bits, with the lower 21 representing the actual character). Thus, I'd actually need to check to make sure that each character wasn't one of these two-part graphemes that would need to have the order remain intact. So, maybe it really is a harder question than I thought ;).
Hey Kaleb, good point on the unicode issue. That trips up a lot of people.
ReplyDeleteI also agree on the coding speed comment.
Nicely done and no, it shoudln't be that difficult.
John: I'm writing from STP but didn't quickly have your email. Would you mind emailing me?
ReplyDeleteyhamilton@redwoodco.com
Your Blog is one of the best top 100 software testing blogs listed in this article:
ReplyDeletehttp://www.testingminded.com/2010/04/top-100-software-testing-blogs.html
but for me, it's just one of the best! Keep the great work!
------------------
If you plan to go in Cameroon, please visit: Offres d'emploi au Cameroun
Hi...Thanks for the post...QA Online Training
ReplyDeleteCoding represents the entire world for some of us and a total mistery for others. That's way life is so coloured.
ReplyDeletePentru cei care au nevoie de achizitionarea mai multor imprimante, magazinele de imprimante second hand sunt cele mai eficiente alegeri.
Thank you for sharing this article .it is very helpul
ReplyDeleteThank you very much. The post was long, but I loved to read it till the last word. It was so nice blog and useful to Informatics learners.................Get More Information and can contact us for Oracle Fusion Financials Course details
ReplyDeleteVery interesting blog to read and to share, thanks for sharing such a good blog. Keep posting more blogs like this thank you....
ReplyDeletePlease Click The Below Link...
Oracle PL SQL Training in Al Karama, Dubai
Nice information. Thanks for sharing.Your blog is really useful for me.
ReplyDeleteOracle Fusion PPM Training in Hyderabad
a nice share thank you worked..
ReplyDeletewww.tamirediyorum.net
The topic is quite interesting. Being a QA engineer I m able to relate with the subject very well. Keep posting more nice content.
ReplyDeleteData Analytics Courses In Nagpur