While going to an interview, there can be anything that the interviewer can ask. You should be ready in all ways 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 focus 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 practicing 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 practicing).
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 that 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 questions 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 the solution?
Just go through your code line by line 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 and easy to understand. The interviewer need not ask, what this line means and what this belongs to.
There is no reason to be nervous in the interview. Even if you stuck if you 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.
Also, you can write up your Interview Experience at GeeksForGeeks.
- How to crack any Technical Interview
- Practice for cracking any coding interview
- 8 Technical Courses To Get a Job in IT
- Socio-technical Systems
- How to get started for technical Interviews?
- 13 Technical Skills You Should Have As A Developer
- Introduction of Technical Report
- Cracking Technical Interviews; Freshers
- Formal Technical Review (FTR) in Software Engineering
- The Technical Scripter Event 2019 By GeeksforGeeks
- Top 5 Common Mistakes in Technical On-site Interviews
- Difference between Research Papers and Technical Articles for Journal Publication
- Write From Home Challenge - Technical Content Writing Event By GeeksforGeeks
- Top 5 Places to Practice Ethical Hacking
- Top 10 Projects For Beginners To Practice HTML and CSS Skills
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.