How to ace a coding interview even if you can't solve the problem
Tags: computerscience, career, interview, coding
Published: 2021-04-09 21:32:34

At most major tech companies, coding problems are the biggest part of the interview process. Some major tech companies have such difficult coding interviews that software engineers often spend months preparing for them. Unfortunately, no matter how much you prepare, it’s impossible to prepare for every problem. The questions in the interviews are designed to be difficult, and they can stump even the most experienced developers. Luckily, there are steps you can take to help yourself get unstuck.

Here, we’ve outlined a process you can follow along with some advice to help you approach even the most difficult problem.

**We will cover:**
* [Taking a deep breath](#part-1)
* [Clarifying the problem](#part-2)
* [Creating good examples](#part-3)
* [Doing it by hand](#part-4)
* [Going simple, then optimizing](#part-5)
* [Taking a hint](#part-6)
* [Next steps for your learning](#part-7)

<a name="part-1"></a>
## Taking a deep breath
The first thing to do when you think you can’t solve the problem is to take a deep breath. Remember that no interview is perfect and that mistakes are expected. These questions are designed to be extremely challenging -- no one will have the perfect answer right away. Even the most seasoned candidates wouldn’t be expected to answer them quickly. From here, there are steps you can take to tackle the problem.

<a name="part-2"></a>
## Clarifying the problem
Before taking it any further, start by clarifying the problem. Sometimes, interviewers will purposely leave out some important details. Asking questions is a good thing and will show your interviewer that you’re thinking deeply about the problem and seeking to understand it better. Asking clarifying questions is a skill that you’ll regularly use as a developer, so your interview is a great place to showcase this skill. 

<a name="part-3"></a>
## Creating good examples
Now that you’ve clarified your understanding of the question, it’s time to create some examples. Think of some possible inputs and what the expected outputs would be for them. Think about a few edge cases that may need special consideration.
> Remember to explain your process out loud. Your interviewer doesn’t necessarily care if you can solve this specific problem perfectly, they care about gaining insight into your problem-solving methods that will lend themselves to the job you’re applying for. 

<a name="part-4"></a>
## Doing it by hand
If a solution doesn’t immediately come to mind, it can be helpful to solve the problem by hand first. Forget that this is a coding interview for a second. If you were asked to solve this problem by hand, how would you approach the problem? Try to reverse engineer your thought process. Sometimes, nerves can cause us to get caught up in algorithms, but take away the coding, and we can quickly arrive at a solution.

<a name="part-5"></a>
## Going simple, then optimizing
It’s much better to have an inefficient solution than no solution at all. A lot of the time, it’s easier to come up with something that simply works. From there, you can discuss steps you could follow to improve it or mention potential bottlenecks and how to fix them. 

<a name="part-6"></a>
## Taking a hint
If you’re totally stuck, it’s okay to ask for a hint. It’s better to ask and actually get somewhere than end up with nothing. If possible, ask for a hint on something specific to give you the best chance of getting unstuck. Remember, your interviewer is on your side and wants to see you do well.

<a name="part-7"></a>
## Next steps for your learning
It seems coding interviews are only getting harder, causing even the most experienced candidates to become stuck. Luckily, you now have a process to follow in case you ever get stuck on a coding problem in an interview. The best thing you can do is to study and prepare as much as you can before your interview. To learn more about how to prepare for your coding interview, check out Educative’s course, [**Grokking the Coding Interview: Patterns for Coding Questions**](https://www.educative.io/courses/grokking-the-coding-interview?affiliate_id=5082902844932096&utm_source=google&utm_medium=cpc&utm_campaign=grokking-ci&gclid=Cj0KCQiA1KiBBhCcARIsAPWqoSpGI906622ESC7ZqU9CasJWwTj4Pt3nLALX1IkWo8MXMumKgcCeLycaAtKXEALw_wcB), where you’ll learn about the 16 patterns for coding questions. The techniques taught in this course have helped developers land jobs at top companies, such as Amazon, Google, Facebook, and Microsoft.

*Happy learning!* 

### Continue reading about coding interviews
- [The Coding Interview FAQ: preparation, evaluation, and structure](https://www.educative.io/blog/coding-interview-faq-preparation-guide)
- [Cracking the top Amazon coding interview questions](https://www.educative.io/blog/crack-amazon-coding-interview-questions)
- [How can I prepare for interviews in any big software company?](https://www.quora.com/How-can-I-prepare-for-interviews-in-any-big-software-company/answer/Fahim-ul-Haq)
- [5 tried and true techniques to prepare for a coding interview](https://www.educative.io/blog/5-tried-and-true-techniques-to-prepare-for-a-coding-interview)