Best approach to solve a problem in a coding interview

By | April 22, 2014

How to approach an interview problem in a coding interview ?
Most of the times the candidate know the answer but still struggle to solve the question and mess up everything .U know why ? Just because the way he approached the problem was wrong .
Based on our experience here we have mentioned a sequence of steps which you I think is the best way to approach a problem in a technical interview.

This is how you should go about solving the problem once the interviewer gives you the question.

  1. Think carefully about the problem and clarify if you have any doubt
  2. Clarify various constraints which can be there don’t just assume things.Like for a question “write a program to sort a list” some valid questions can be :
    • what kind of datatype the list is holding ? (Interviewer: Integers)
    • Is this list holding number in a specific range?(Interviewer : Yes)
    • Am I allowed to use extra space(Interviewer : Yes)
    • So see now you can comeup with an O(n) solution using counting sort.
  3. Prepare a rough draft of your code .Which will have what classes will be involved in the solution , what methods will be there and the basic flow
  4. Most of the interviewers are trained to take interviews , so if you are going in wrong direction he will give you hints try to catch those hints .
  5. Write the final code
  6. Before giving your solution to the interviewer do a dry run .Test it yourself specially on boundary cases

Still have some doubt ,feel free to contact us.We will be happy to help you.

Leave a Reply

Your email address will not be published. Required fields are marked *