Developers

7 steps to improve your data structure and algorithm skills

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:

Step 1: Understand Depth vs. Breadth

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:

Focus on less problems, not more

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:

  1. You can code it quickly
  2. You can code it with correct syntax, which means you are good at the language
  3. You can write clean code in one go, because it’s second nature to you
  4. You can apply the same code to a new problem quickly
  5. You know the data structure you are using and can implement it if asked to

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.

Step 2: Start the Depth-First Approach—make a list of core questions

Identify a list of ~100 core problems. Many sites give you 100 curated problems.

Here’s another way:

Get these two books:

  1. Elements of Programming Interviews
  2. Cracking the Coding Interview.

Collectively, they give you a good variety of hand-picked problems.  If you want a structured course for this, check out InterviewCamp.io

Step 3: Master each data structure.

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.

Here is a list of data structures to master :

  • Arrays and Lists
  • 2D Arrays
  • Strings
  • Linked List
  • Stack
  • Queue
  • Hash Table & Hash Set
  • Heap
  • Graphs
  • Binary Tree
  • Binary Search Tree
  • Trie

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.

(Check HackerEarth Data Structure & Algorithm practice)

Step 4: Spaced Repetition

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.

Step 5: Isolate techniques that are reused. Isolate actual code blocks.

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:

  • Depth First Search
  • Recursion + Memoization
  • Hash Table + Linked List combination
  • Searching a Binary Tree etc.

Now, you have a collection of techniques you can apply to new problems.

Step 6: Now, it’s time for Breadth.

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.

Step 7: Practice on paper

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:

  1. You’re forced to plan your code before writing. You can’t just go back and retype.
  2. You will start learning correct language syntax and data structure usage. With an IDE, code used to write itself.
  3. You can take a paper and pen anywhere with you to practice.

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

Harsh Goel

Harsh runs InterviewCamp.io, one of the largest courses for tech interview prep. Before that, he worked as an engineer at Google and Pinterest.

Share
Published by
Harsh Goel

Recent Posts

Recruitment Management System – An Ultimate Guide

Defining a Recruitment Management System In today's competitive talent landscape, attracting and retaining top performers…

3 weeks ago

Create Your Recruitment Funnel in 7 Simple Steps

Understanding the Recruitment Funnel Imagine a broad opening at the top, gradually narrowing down to…

3 weeks ago

Skills Assessment Test: How It Works, Benefits & Examples

With the growing demand for highly skilled professionals, traditional hiring methods such as reviewing resumes…

3 weeks ago

Recruitment Workflow Process: A Complete Guide

Finding the perfect fit for your team can feel like searching for a unicorn. But…

3 weeks ago

Conquer Your Hiring Challenges: Top Recruiting Software Picks for Small Businesses in 2024

In today's competitive job market, attracting and keeping top talent is crucial for small businesses…

4 weeks ago

How To Become A Technical Recruiter: Your Guide to Launching a Rewarding Career

The tech industry thrives on innovation, and at the heart of that innovation lies a…

4 weeks ago