I gave my first coding interview in 2016—and failed. I failed the next five interviews as well before finally landing my first job at Morgan Stanley.
Since then, I’ve interviewed with many companies and faced my fair share of rejections. However, over the years, my failure rate in coding interviews dropped significantly.
By 2022, with just 1.5 months of focused preparation, I successfully cleared interviews at Amazon and Google.
Surprisingly, my success wasn’t due to a dramatic improvement in problem-solving skills. The real game-changer was my approach—how I prepared and what I prioritized during the interview.
In this article, I’ll share 20 essential tips that made coding interviews significantly easier for me.
These tips cover everything you need to know, including:
How to systematically approach coding interview problems
Key concepts and patterns you should know
The type of problems you should practice
How to choose the right algorithm for a given problem
Techniques to optimize your solution
How to communicate your thought process effectively
… and much more
By applying these strategies, you’ll be able to tackle coding interviews with confidence and massively increase your chances of success.
1. What Interviewers Are Looking For
In a coding interview, interviewers want to see how well you think, communicate, and code under pressure.
Here's a breakdown of what they look for:
Understanding the problem: Do you ask clarifying questions instead of making assumptions to ensure you fully understand the problem?
Breaking down complexity: Can you decompose the problem into smaller, manageable parts?
Efficiency: Can you design an optimal solution in terms of time and space complexity?
Edge cases: Do you handle edge cases like empty inputs, duplicates, large values, or special conditions?
Trade-offs: Can you explain why one approach is better than another?
DSA Knowledge: Do you have a strong grasp of data structures and algorithms, and can you choose the right one for the problem?
Complexity Analysis: Can you quickly compute the time and space complexity of your solution?
Explaining your thought process: Can you clearly articulate your approach and why it works?
Handling hints: Are you receptive to hints and able to adjust your approach accordingly?
Clean and readable code: Do you follow good coding practices (meaningful variable names, proper indentation, modular functions etc..)?
Improving the initial solution: Can you optimize and refine your first solution when prompted?
Follow-up Questions: Are you able to tackle variations of the original problem?
Testing: Can you manually walk through your code with sample inputs to verify correctness?
2. Allocate Time Wisely
Most coding interviews last 45-60 minutes.
Depending on the company and interviewer, you may be asked to solve 2-3 easy/medium problems or 1 hard problem with follow-ups.
Lets assume you are given one problem, with a follow up in a 45-minute interview. Here’s how you can optimally allocate your time:
Introduction (0-5 mins): The interviewer may ask you to introduce yourself. Prepare a concise 1-2 minute introduction that highlights your background, experience, and key strengths. Practice it beforehand so that you can deliver it smoothly.
Understand the Problem (5-10 mins): Carefully read the problem statement, ask clarifying questions, and walk through sample inputs and expected outputs.
Plan the Approach (10-20 mins): Brainstorm possible solutions, evaluate trade-offs, and discuss time and space complexity.
Implement the Code (20-30 mins): Write a clean, modular and readable code.
Testing (30-35 mins): Dry-run your code with sample inputs, debug any issues, and ensure edge cases are handled.
Follow-ups and Wrap Up (35-45 mins): Answer follow up questions, and ask thoughtful questions to the interviewer about the company, role, or team.
3. Understand the Problem Well
One of the biggest mistakes candidates make in coding interviews is jumping into coding too soon.
If you don't fully understand the question, you might end up solving the wrong problem.
Here’s how to ensure you grasp the problem before coding:
Read the Problem Carefully
Take a moment to absorb the problem statement. Rephrase it in your own words to confirm your understanding.
Identify the expected input/output format and any hidden constraints.
Ask Clarifying Questions
If anything is unclear, ask questions before diving into the solution. Interviewers appreciate when you seek clarity. Never assume details that aren’t explicitly mentioned in the problem statement.
Common clarifications include:
Are there duplicate values?
Can the input be empty? If so, what should the output be?
Should the solution handle negative numbers?
Should the output maintain the original order of elements?
Is the graph directed or undirected?
Does the input contain only lowercase English letters, or can it have uppercase, digits, or special characters?
What should happen if multiple solutions exist? Should I return any valid solution, or does the problem have specific requirements?
Walk Through Input/Output Examples
Once you understand the problem statement and constraints, go over a few input and output examples to make sure you get it.
Draw them out if it helps, especially for visual data structures like trees or graphs.
Try to take examples that cover different scenarios of the problem. Think about any edge cases that might come up.