DEV Community

Cover image for How to ace a coding interview even if you can't solve the problem
Erin Schaffer for Educative

Posted on • Originally published at educative.io

How to ace a coding interview even if you can't solve the problem

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

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.

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.

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.

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.

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.

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.

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, 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

Top comments (0)