This blog is a guest contribution from Harsh Goel, Founder @ InterviewCamp.io – Online Bootcamp for Technical Interviews
Machine Learning or Blockchain might be the next big thing, but interview problem-solving is the skill of the decade.
Here is a step-by-step plan to improve your data structure and algorithm skills:
We all have that friend who has solved 500 coding problems. They love to wear it as a badge of honor. But when it comes to interviews, they fail miserably. This is a very common scenario. It’s what we call the “Breadth-Only” approach. They are solely focused on solving as many problems as they can.
The Breadth-Only approach has a problem—you don’t build a strong foundation. Interviews require deep problem-solving knowledge and the ability to code fast and accurately. You only develop these skills with focused preparation.
Here’s a counter-intuitive approach that works better:
This is comforting, right? Who wants to focus on 500 problems when you can focus on 100?
But here’s the key—you want to learn them in depth. This is where depth comes in.
When you analyze a problem in depth, it means:
To achieve this, you need to focus on a few representative problems (around 100 works well.) Solve them a few times and you’ll start seeing patterns. You also start getting better at the coding part.
So you’ve covered Depth, congratulations! You have acquired a solid base.
You can now go all out and solve as many problems as you want. And best of all, you won’t need to code many of them. Figure out a solution, and if it’s similar to one of your core problems (which it often is), you’re done. No need to actually code and debug it because you’re already good at that.
Identify a list of ~100 core problems. Many sites give you 100 curated problems.
Here’s another way:
Get these two books:
Collectively, they give you a good variety of hand-picked problems. If you want a structured course for this, check out InterviewCamp.io
Now that you have finalized your list, start with the basics. Know every data structure.
Learn how to use each data structure in your language.
Also, learn how to implement them. Yes, implement them by hand. Many people ignore this, but it’s extremely important. Interviewers can ask you about data structure internals. Many problems modify data structures or re-engineer them for a specific use case. To utilize them fully, you need to know how they work.
For example:
Interviewer: “So you initialized an array-backed list. Good. Now let’s say you reach its capacity, what happens when you try to add another element?”
Candidate: *blank* “What do you mean capacity? I can keep adding elements to this list.”
Interviewer: *facepalm*
In this case, the candidate had been using Python, and there’s no concept of list capacity. You just keep adding elements. But that’s not what happens under the hood. You need to know what data structures back a list, and how that works.
Here’s another example:
Let’s say you’re asked to Implement a Queue using just Stacks (a popular question). This is a modified data structure. If you haven’t implemented either of those before, you’ll have trouble getting started.
Now, this doesn’t mean you need to know every implementation’s code. Some data structures are pretty hard to implement – for example, deleting a node from a Binary Search Tree is not trivial to code. But you should know how it works.
How to go about it? Let’s say your core problems are divided by data structure. You can master each data structure when you start each section. Or, you can master them all at the beginning. Do what works for you.
Alright. You made a list of questions and you started solving them. Here’s a common question we get:
“I solve many questions but can’t solve them a week later! How do I remember solutions?”
The key is to not remember solutions. The key is to practice them. When you see a problem, you should immediately be able to break it down and re-create the solution. This is different from rote learning. You’re recognizing different components, breaking them down and solving the problem.
The best technique we’ve seen – solve the problem again in 3 days. Then in a week. Then in a month. It will become second nature to you.
This is where the Depth-First approach gets exciting. As you solve these problems, you’ll start to notice patterns.
Let’s say you solved 5 problems that used Binary Search. You can isolate the Binary Search code and practice it over and over. You know it will be used in similar problems.
And this is one of many techniques you can isolate. Here are some other common ones:
Now, you have a collection of techniques you can apply to new problems.
Let’s say you’ve mastered your core problems. Using common data structures is second nature to you. You can now look beyond your core set. Because you’ve implemented so many techniques already, you don’t even have to code all the new questions.
During this time, try to solve realistic interview problems. Once you get good, there’s a tendency to focus on really hard problems. The thought process is – “if I can solve these really hard problems, then interview problems will be a piece of cake!”. That’s not usually the case. Techniques in really hard problems often have nothing to do with interview-level problems.
We recommend practicing on paper at some point in your prep. When you code without an IDE and Stack Overflow, it takes you away from your comfort zone.
Here are some benefits of practicing on paper:
And more importantly, it is a realistic simulation of a whiteboard interview.
Congratulations, you’re now a pro! Let’s get those interviews rolling.
Also read – Top 7 algorithms and data structures every programmer should know about
Organizations of all industries struggle with employee turnover. The high turnover rates cause increased hiring…
Virtual hiring events are becoming vital for modern recruitment, and the hiring world is changing…
The competition for talent today is intense, and this makes it very important for organizations…
Hiring trends are continuously evolving over the ages to keep pace with the latest technological…
Hiring practices have changed significantly over the past 30 years. Technological advancements and changing workforce…
In the current world, where the hiring process is ever-evolving, it has become crucial to…