While going to an interview, there can be anything that the interviewer can ask. You should be ready in all way for the interview whether it is from Resume, programming skills to dressing sense and gesture. There is a lot to be ready for the different rounds to be held.

The most important round in the interview is the Technical Round. And a lot of technical rounds focuses on the Programming questions. Mostly you will be presented with a pen and paper and asked to suggest an algorithm to solve the question followed by the code.

For cracking the Technical round, you should practice the problem exactly as you will be in the interview. Following a systematic approach and practising it will allow you not only to solve these problems but to solve so many others in his interview.

Here are some of the steps that you should follow:

  1. Understand the Problem:
    While this sounds to be obvious, but commonly this step is missed. It is very important to understand the problem clearly before attempting to solve it. If you didn’t understand, read it again until you understand the problem.
    For Ex: Many interviewers ask a question on to reverse a linked list and most of the people spend a lot of time in traversal and changing the pointers, rather than using a simple stack-based solution.
    Understanding exactly what is asked to you is key to your success. Ask any clarifying question which looks necessary (to the interviewer while interview and yourself while practising).
    Time for your eagle eyes: Observe at the inputs, outputs (in the given example) and constraints given, you may have to look a couple of times.
    Then find out the critical and edge cases, and add these cases in your examples.
  2. Find a brute force solution:
    It is essential that you should start with a brute force solution. Too many people try to jump into an optimized solution and get lost. At that point, it can be very hard for you to recover, without starting from the beginning, and in an interview, you have no time to start it from the beginning.
    The brute force solution makes you really understand the problem without worrying about optimizing your solution. You know what your input will be and exactly how it needs to be modified to get to the output.
    Now, you also have a solution. Even a bad solution is way better than no solution.
    Last but not least, a brute force solution gives you a jumping-off point from where you can optimize your code. Once you have a brute force solution, you can use many different techniques to improve your time and space complexity (you may come up with a solution using Dynamic Programming or some more efficient data structure).
  3. Optimize your Code:
    Here is the step where you can shine, come up from the crowd. This the step where you have a chance to make your algorithm as efficient as you can. There is plenty of approaches which you can try here, whether using a more efficient data structure or using dynamic programming, looking at the duplicated(repetitive) tasks in your code. Or you may come up with a new more efficient unrelated brute force solution.
    Remember, this the step where you can come forward from the crowd and shine. Usually, in Interviews, interviewers generally help you to come up with a better solution by some hints, you need to grab the opportunity.
  4. Code the solution:
    Till now, you have done all the leg work, all tools are sharpened. Coding should be an easy task now. But it needs a lot of practice. Practice as much as you can. Do practice question up to the coding solution. Mostly, people quite the question after getting the logic. More you practice for writing code, more it will be easier for you in interviews.
  5. Test your solution:
    This is the final step and critical too. Mostly, people are overconfident (or maybe nervous) they do not test there a solution and show to the interviewer.
    Testing your solution will give confidence that your solution is correct. You can say it confidently that “Yes! my solution is correct.”
    But how to test my solution?
    Just go through your code line by line (I suggest this) because it guarantees that your code does not have simple typos and indexing errors. These errors can leave a bad taste to the interviewer even if you did well.

One more important thing, while writing your code to be sure that it should be clean easy to understand. Interviewer need not ask, what this line means and what this belongs to.

In conclusion, I would say that there is no reason to be nervous in the interview. Even if you stuck, if follow steps you may come up to some solution. For this, there is only one key to solve the programming questions
i.e.
Practice.
More you practice better you will perform.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store