Computer Science Canada

How would you fare in an interview?

Author:  wtd [ Sat Mar 03, 2007 8:59 pm ]
Post subject:  How would you fare in an interview?

A task that might be posed in an interview:

Write a function which prints the numbers from 0 to 100. But, for each multiple of 3, it prints "Fizz" instead of the number. For each multiple of 5, it prints "Buzz" instead of the number and for multiples of both 3 and 5, it prints "FizzBuzz" instead of the number.

Don't post code for this, just write it out on paper. Pick whatever language you please, but no psuedocode.

Can you do it in a few minutes?

Congrats! Surprisingly few programmers applying for jobs even at the senior level can manage this.

Now, test your code. Did it produce the correct output?

Even fewer programmers get the function right if they can write it at all.

Author:  md [ Sat Mar 03, 2007 9:11 pm ]
Post subject:  RE:How would you fare in an interview?

Heh, it really is surprising how many people can't actually do this.

Author:  neufelni [ Sat Mar 03, 2007 9:25 pm ]
Post subject:  Re: How would you fare in an interview?

I tried it, and sadly, I was unsuccessful. I had a few little mistakes. I used Python, and forgot the () in my function declaration and the function call. Also didn't make it so that it didn't count 0 as a multiple of 3 or 5.

Author:  wtd [ Sat Mar 03, 2007 9:31 pm ]
Post subject:  Re: How would you fare in an interview?

neufelni @ Sun Mar 04, 2007 10:25 am wrote:
Also didn't make it so that it didn't count 0 as a multiple of 3 or 5.


This was not required.

Author:  bugzpodder [ Sat Mar 03, 2007 9:32 pm ]
Post subject:  RE:How would you fare in an interview?

I read about that, and I don't believe it. Anyone who has more than 1 year of programming experience should have NO problems doing this. After all, it just consists of a loop, an if statement and output.

Author:  Clayton [ Sat Mar 03, 2007 10:38 pm ]
Post subject:  Re: How would you fare in an interview?

bugz, the keyword there is *should*. Sure anyone with half a brain should be able to write that program, but without a keyboard and a monitor in front of them, many people seem helpless. Then they also have to worry about stupid little mistakes because they have no debugger to tell them they screwed up in their code. It's more of a mental thing if you ask me.

Author:  bugzpodder [ Sat Mar 03, 2007 11:11 pm ]
Post subject:  RE:How would you fare in an interview?

thats not the point. the interviewer also has no debugger so he/she can't compile your code mentally. If he catches a mistake you didn't, just fix it. phasing out on paper is a different issue, the original post on a blog implies that many people can't do this period (do a search on fizzbuzz) which i think is a ridiculous claim.

Author:  Tony [ Sun Mar 04, 2007 12:22 am ]
Post subject:  RE:How would you fare in an interview?

I read the blog post, 199 of 200 seems to be an exauguration. Although writing code on a blank sheet of paper, with interviewing developers watching the clock is intimidating... I can see myself making some mistake, if the language choice is not mine.

Author:  bugzpodder [ Sun Mar 04, 2007 1:18 am ]
Post subject:  RE:How would you fare in an interview?

they should be asking people to write a variant of binary search (returns the first position if the item is not in the list). i think thats a pretty good interview question.

Author:  Martin [ Sun Mar 04, 2007 2:56 pm ]
Post subject:  RE:How would you fare in an interview?

Easy!

code:

cout << "FizzBuzz\n1\n2\nFizz\n4\nBuzz\n...";


I thought about making a program to make this program, but I thought that'd be overkill.

Author:  wtd [ Sun Mar 04, 2007 3:11 pm ]
Post subject:  RE:How would you fare in an interview?

And what does everyone miss?

They fail to generalize the solution. There are all kinds of hard-coded values in the solutions. Wink

Author:  bugzpodder [ Sun Mar 04, 2007 9:06 pm ]
Post subject:  Re: How would you fare in an interview?

yeah for the people who says they google employees. just take my example, unless i disclose my online id is bugzpodder, there is no way in hell they are going to find anything about me on google. and a lot of people have common enough names for this not to happen. in fact, i tend to google my interviewers and often i find nothing. what makes he think he can find (correctly) his candidates?

Author:  octopi [ Mon Mar 05, 2007 12:12 am ]
Post subject:  Re: How would you fare in an interview?

I don't know how people could do that bad, I just wrote 6.5kb of php code (using notepad) off the top of my head, without testing it, when I did test it, I was missing a single semicolon that was my only mistake (and it was mostly just a speed of typing error, not that I thought I didn't need it), and this program I made was more complicated then the one required in the example interview (deals with mysql etc..)

I really don't see how that many people could get it wrong...

Author:  klopyrev [ Mon Mar 05, 2007 2:20 am ]
Post subject:  Re: How would you fare in an interview?

What an odd question. Didn't take me too long. Only mistake I made was that I didn't have a newline character at the end of my main method and my compiler complained. Why does it do that? (strange). I remember my brother, who now works at Google(Razz), was researching interview questions because he had to interview people at the company. He asked me a sample question, and it wasn't as easy as that. For the one he asked me, you actually had to use logic. He even asked me to tell him a few questions from Olympiads that he might use. I don't believe interviews should be that easy. I don't believe they are that easy. Then again, I guess it really depends on the position you are applying for and the company you are applying at.

KL

Author:  Martin [ Mon Mar 05, 2007 3:36 am ]
Post subject:  RE:How would you fare in an interview?

You have to weed out people in different levels. I've been asked some weird interview questions.

The "reverse a string in place" question is pretty common, as well as the "reverse a linked list."

Joel from Joel on Software has a good essay on interview questions here

Author:  Martin [ Mon Mar 05, 2007 8:19 am ]
Post subject:  RE:How would you fare in an interview?

Oh!

My favourite interview question is, "what is the output of the following?"

code:

int a = 2;
a += a++;
cout << a << endl;


what would it be if line 2 was a+= ++a? a += ++a++?

Answer:
Quote:

5, 6, error

Author:  bugzpodder [ Mon Mar 05, 2007 9:54 am ]
Post subject:  RE:How would you fare in an interview?

Not everyone is a guru in programming contests. and unless Google only plans to hire interns, not many professionals will be well-versed in algorithms to solve such problems.

to ask IOI questions in a Google interview is like asking an architect to design a building in one hour. Before posing it to candidates, he should see if he is able to do it under the time constraints.

and if it makes anything different, I just rejected an offer from Google. They haven't offered me any reason at all to why I should work for them.

Author:  Tony [ Mon Mar 05, 2007 4:41 pm ]
Post subject:  RE:How would you fare in an interview?

heh Martin, ++a++ one is tricky.

bugz - is Morgan Stanley really paying that much more than Google?

Author:  klopyrev [ Mon Mar 05, 2007 5:24 pm ]
Post subject:  Re: How would you fare in an interview?

Quote:

to ask IOI questions in a Google interview is like asking an architect to design a building in one hour. Before posing it to candidates, he should see if he is able to do it under the time constraints.


I didn't mean IOI questions. Asking IOI questions on an interview would be really mean. I believe interview questions should be based on logic. The a++, ++a++ one wouldn't make a great interview question in my opinion - at least for the logical thinking part. Anyway, did anyone else actual read Joel on Software? I found it in my brother's book collection and decided to read it. Turned out to be such a fascinating book. Couldn't stop reading.

KL

Author:  bugzpodder [ Mon Mar 05, 2007 5:43 pm ]
Post subject:  RE:How would you fare in an interview?

since when is it about the money? I chose Morgan stanley because I want to check out the finance industry to see if it is good for me. In fact, i dont even know what they pay at Google, since no one bothered to contacted me about anything before rankings finished (i couldnt get in touch with anyone from google).

Author:  Cinjection [ Mon Mar 05, 2007 6:11 pm ]
Post subject:  Re: How would you fare in an interview?

I hope that it's true that most programmers can't do that uynder pressure (which i doubt). In today's competetive market, these little things that make you look better to the employer are definetly welcomed, to me at least. I really doubt the question with the multiples is on any interview. That's overly easy. In the first computer science course i ever took(make that taking), modulos came up within the first week.

Author:  Martin [ Tue Mar 06, 2007 8:34 am ]
Post subject:  RE:How would you fare in an interview?

Morgan Stanley is in New York City. You're gonna have so much fun bugz, I'm way jealous.

Microsoft is famous for their interview questions, search around and you'll find some good ones.

And klopyrev, I did read Joel on Software. It was pretty well written I thought. If you liked that, you should check out Dreaming in Code by Scott Rosenberg and also Paul Graham's essays. I also bought a copy of Founders at Work, but I haven't had the chance to read it yet.

Author:  michaelp [ Thu Aug 09, 2007 2:01 pm ]
Post subject:  RE:How would you fare in an interview?

I tried doing this. (Not on paper, a normal computer)
I couldn't do it.
Not that I've been programming for a long time or anything.


: