JOIN
Get Time
forums   
Search | Watch Thread  |  My Post History  |  My Watches  |  User Settings
View: Flat (newest first)  | Threaded  | Tree
Previous Thread  |  Next Thread
Coding interview etiquette | Reply
I have some questions about etiquette for a coding interview:

1. Are we expected to write comments for the code?
2. Should I write driver methods (main) or stand-alone functions are sufficient?
3. Should I explain my solution as I am coding or can I leave the explanation until the end?
4. How much emphasis is given to the coding speed?
Re: Coding interview etiquette (response to post by dimkadimon) | Reply
Disclaimer: I only have a short experience as an interviewee for software engineer internships, other roles may have different expectations.
I applied and got internship offers from Google and Facebook. Based on my interviews and the advice I read about interviewing with these type of companies:

1. Are we expected to write comments for the code?
No. However, code quality is also valued. Structuring the solution in functions (or classes if it is a high level question) and using meaningful variable names is good. If the interview is on a whiteboard, it's normal to use shorter names to write less.

2. Should I write driver methods (main) or stand-alone functions are sufficient?
Usually, the questions are more like "Write a function that given X, does Y". No main() or testing code required.

3. Should I explain my solution as I am coding or can I leave the explanation until the end?
Coding takes a lot of interview time. It's better to discuss the solution ideas before coding. The goal is to make sure you're going in the right direction before coding the solution. Then, explain what you're doing while coding.
If it's something really simple like a warm-up question, say reverse a string, then I think it's ok to write code right away (but explain what you're doing).

4. How much emphasis is given to the coding speed?
Speed matters, but I think it's more about the time taken to solve a question rather than coding speed.
It's more like "This candidate spent the whole interview on the FizzBuzz question, reject" vs "The candidate was able to progress until here, discussing X, Y and Z".
The interviewers typically have asked the same questions to a lot of people. So, the interviewee performance is compared with the past applicants.


I recommend watching this video where a Facebook engineer goes through an interview question and gives tips. There are also a lot of questions about preparation and tips on Quora.

edit: typo.
Re: Coding interview etiquette (response to post by mogers) | Reply
Thank you for your answers - they have been very useful to me, especially 3. It is important to know how the interviewer is thinking and evaluating you. This should help me to maximise my chances. I have a few more questions:

1. Is it ok to ask about input constraints? I want to ask about data types and array sizes before proceeding with my answer.

2. Should I always present the simplest solution (brute force) first and then give the efficient solution? Or should I go straight for the efficient solution?
Re: Coding interview etiquette (response to post by dimkadimon) | Reply
1. Is it ok to ask about input constraints? I want to ask about data types and array sizes before proceeding with my answer.

Sure, it's actually good to do so. In certain cases like queries over some data, you may also discuss if you can do some preprocessing in order to answer the queries faster.
Checking corner cases like "can the input be an empty list or even null?" is also good.

2. Should I always present the simplest solution (brute force) first and then give the efficient solution? Or should I go straight for the efficient solution?

I've seen mixed advice on this one. I think the most important thing is to produce a correct and working solution.
In a coding question, my preference is to talk about the most efficient solution I'm confident I can code in the interview. Still, if the question is complex, it's good to talk about different approaches, e.g. 2 nested cycles lead to a N^2 solution (...) if we use a binary search tree, (..) we can do it in N log N.
Re: Coding interview etiquette (response to post by dimkadimon) | Reply
Here are answers to above from a Google recruiter (I hope it is ok to post these).

1. Are we expected to write comments for the code?
No, the interviewer will be viewing in real time your code so if they have any questions they will ask at the time.

2. Should I write driver methods (main) or stand-alone functions are sufficient?
This is unlikely to be relevant considering the types of questions we ask but either way it's best to ask the interviewer as you go.

3. Should I explain my solution as I am coding or can I leave the explanation until the end?
Probably ok either way but again, different interviewers have their own preferences so probably best to ask.

4. How much emphasis is given to the coding speed?
Some but it is not the main driver. If you are taking a lot of time, this of course means that you won't be able to get through much content. I'd suggest going quickly but not at the detriment of your accuracy.
Re: Coding interview etiquette (response to post by mogers) | Reply
1. Is it ok to ask about input constraints? I want to ask about data types and array sizes before proceeding with my answer.
From what I have read it is actually a good idea to ask questions before coding. In fact, if you jump into code straight away it shows that you are rushing and not thinking. Also the questions are often under-specified on purpose to check your ability in extracting the problem requirements.

Jumping into code is one bad habit that TC has taught me and I really need to get out of it.
RSS