This is a guest post from Daniel Chae, an experienced programmer and data analyst in Los Angeles, CA that is also passionate about helping people learn to code.
Coding can be tough when you’re trying to solve a problem, but you don’t know what you should do to come up with a solution. Things only get worse when you get stuck during a technical interview.
One of the best tips I’ve received for acing interviews is to explain my approach. Interviewers use this practice to test a candidate’s problem solving skills. I’d love to share with you how this tip has helped me with my interviews. I’ll also talk about why explaining your approach is so important for you moving forward. As I do this, I’ll speak about my own interview at Google and a few more personal stories of how this tip has benefited me.
What does “explain your approach” mean?
Explaining your approach involves two things. First, you must identify your core goal. Second, you must generate a step by step process that you can say out loud. You may not end up with the most perfect solution, but that’s okay. The purpose of explaining your approach is to help you get started with solving the problem. Then you can identify the exact steps necessary to build a streamlined solution.
Let’s try this out on a common coding exercise for beginners, Fibonacci’s sequence. The exercise asks you to print out a set of numbers where each number is a sum of all previous numbers. Your core goal would be as follows:
Core Goal: print out a sequence of at least seven numbers where each number is the sum of all previous numbers. Start with 0 and 1.
The second action involves generating steps the problem requires. Then say the step out loud as you write the corresponding code. You can do this with writing these out, comments in your IDE, or pseudocode. Using Fibonacci’s sequence, here’s a set of steps you might come up with:
Steps required to solve the problem:
1. Create variable, a, to store 0 and variable, b, to store 1
2. Sum ‘a’ and ‘b’
3. Store the sum in variable c
4. Sum ‘a’, ‘b’, and ‘c’
5. Store the sum of ‘a’, ‘b’, ‘c’ in variable, ‘d’
6. Repeat until I could print seven numbers where each number was a sum of all preceding numbers.
If you look at the steps, you’ll notice it’s not the perfect solution. Again, that’s okay. The purpose of explaining your approach is to help you get started. Then you can use the steps you identified to build a more streamlined solution.
How I used “explaining my approach” during my Google interview
After learning how to explain my approach, I ended up landing an interview with Google. The interview was for a software development role with a Legal team. The interview day arrived and I got around to the technical interview. The first question was a whiteboard question. The interviewer told me to imagine a CSV file of jumbled numbers. She then asked me how I would organize the numbers into full 10 digit telephone numbers. The prompt felt vague so I didn’t know how I would go about solving the problem. But then I remembered I could explain my approach as a way to try and find a solution. I thought about the interviewer’s prompt and identified my core problem:
Core Problem: Organize a CSV of jumbled numbers into full, 10 digit telephone numbers.
Then I broke the problem into several steps. Here were my steps for solving the problem:
1. Access CSV file
2. Print out all numbers in the CSV
3. Create a new CSV file where I could store the full, 10 digit telephone numbers
4. Print seven numbers at a time
5. For each set of seven numbers, write the full, 10 digit telephone number to new CSV file
I finished writing my steps on the whiteboard and started writing the code for each step. I verbalized each step as I wrote the code for each corresponding step. After five minutes of doing this, I finished my solution. The interviewer took some time to review my work, which made me a bit nervous. After five minutes had passed, she let me know my solution wasn’t perfect. But she clarified that me explaining my approach made up for not having a perfect solution. She told me she was more interested in my thought process rather than my solution. Google ended up offering the role to someone who had several more years of experience. But they said I did well in the technical interview, even though I didn’t come up with the perfect solution.
How explaining your approach will help you through interviews
Explaining your approach will assist you in two significant ways. The first way is that you’ll have a solid strategy for generating a solution. You’ll have an increased clarity for accomplishing the task at hand. If nothing else, you’ll have a better chance at solving the problem.
Answering a technical interview question can be tough. Technical questions are tough especially if you haven’t practiced the problem beforehand. I practiced solving several questions before my Google interview. But I didn’t practice any questions with a CSV file. That said, explaining my approach helped me ace the interview. I was able to nail down the core problem I needed to solve and set the foundation for formulating an approach.
The second way is that you’ll give your interviewer a clear view of how you’re approaching a problem. Google interviewers aren’t the only ones who value the thought process. Interviewers across most companies want to see how you will tackle a problem. A solution isn’t worth much if you’re not able to explain how you got there.
I wasn’t excited to hear from the Google interviewer that my solution wasn’t as good as it could have been. But I was more happy than I was sad to know that I performed well on the interview despite not having a perfect answer. I went on to interview at two more companies after Google. Each respective interviewer was like the Google interviewer. They each told me they wanted to see my thought process, even at the expense of a perfect solution.
Now you can ace interviews and land a job
Explaining my approach has become one of my favorite problem solving tactics. It’s one of my go-to strategies for getting through interviews. It has helped me solve countless whiteboard problems and land several job offers.
As you go through interviews, I encourage you to explain your approach to the interviewer. Tell them about what you think the core problem is and the steps you think you need to take to arrive at a solution. Who knows, this approach could be what lands you your next job!