Find out how HackerEarth can boost your tech recruiting

Learn more
piller_image

7 steps to improve your data structure and algorithm skills

data structure, algorithms, data structure and algorithms, interview prep, interview camp. HackerEarth, Data structure practice

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

Hackerearth Subscribe

Get advanced recruiting insights delivered every month

Related reads

Best Interview Questions For Assessing Tech Culture Fit in 2024
Best Interview Questions For Assessing Tech Culture Fit in 2024

Best Interview Questions For Assessing Tech Culture Fit in 2024

Finding the right talent goes beyond technical skills and experience. Culture fit plays a crucial role in building successful teams and fostering long-term…

Best Hiring Platforms in 2024: Guide for All Recruiters
Best Hiring Platforms in 2024: Guide for All Recruiters

Best Hiring Platforms in 2024: Guide for All Recruiters

Looking to onboard a recruiting platform for your hiring needs/ This in-depth guide will teach you how to compare and evaluate hiring platforms…

Best Assessment Software in 2024 for Tech Recruiting
Best Assessment Software in 2024 for Tech Recruiting

Best Assessment Software in 2024 for Tech Recruiting

Assessment software has come a long way from its humble beginnings. In education, these tools are breaking down geographical barriers, enabling remote testing…

Top Video Interview Softwares for Tech and Non-Tech Recruiting in 2024: A Comprehensive Review
Top Video Interview Softwares for Tech and Non-Tech Recruiting in 2024: A Comprehensive Review

Top Video Interview Softwares for Tech and Non-Tech Recruiting in 2024: A Comprehensive Review

With a globalized workforce and the rise of remote work models, video interviews enable efficient and flexible candidate screening and evaluation. Video interviews…

8 Top Tech Skills to Hire For in 2024
8 Top Tech Skills to Hire For in 2024

8 Top Tech Skills to Hire For in 2024

Hiring is hard — no doubt. Identifying the top technical skills that you should hire for is even harder. But we’ve got your…

How HackerEarth and Olibr are Reshaping Tech Talent Discovery
How HackerEarth and Olibr are Reshaping Tech Talent Discovery

How HackerEarth and Olibr are Reshaping Tech Talent Discovery

In the fast-paced tech world, finding the right talent is paramount. For years, HackerEarth has empowered tech recruiters to identify top talent through…

Hackerearth Subscribe

Get advanced recruiting insights delivered every month

View More

Top Products

Hackathons

Engage global developers through innovation

Hackerearth Hackathons Learn more

Assessments

AI-driven advanced coding assessments

Hackerearth Assessments Learn more

FaceCode

Real-time code editor for effective coding interviews

Hackerearth FaceCode Learn more

L & D

Tailored learning paths for continuous assessments

Hackerearth Learning and Development Learn more