From Zero To Hero in Data Structures & Algorithms

Tushar Patil
5 min readJul 24, 2022

--

How To Prepare For DSA

Hello, Tushar here. Recently, I shared my journey of getting into Cisco from Tier-3 college and Non-CS branch.

Data Structures & Algorithms (DSA) played a huge role in my journey. And if you are targeting product based companies, then you have to be well-versed with the DSA concepts.

I have solved more than 2000+ problems on platforms like LeetCode(850+), Codeforces (950+), GFG (200+),etc.

Now, don’t get overwhelmed by these numbers. Anyone can achieve these stats.

How?

Well this blog will answer your question.

Prerequisites Before Starting DSA

You should have a base knowledge of any one programming language (CPP, JAVA or PYHTON).

Don’t go too deep into the programming language at first, just basic concepts like conditional statements, loops, pattern printing and basic questions (prime, Armstrong, palindrome, etc) are enough.

It will take somewhere between 15–30 days to learn a language.

DSA Topics

You have to prepare all the DSA topics in order to have complete understanding. Companies can ask from any of the below topics.

At first it may look like the topic is tough but with time you will get the grasp of the topic by solving the problems regularly.

→ Learn “Object Oriented Programming” along with DSA
→ Math [Factors, Primes (Sieve Of Eratosthenes), Modulo Arithmetic, GCD]
→ Array
→ String
→ Linked List
→ Greedy Algorithm
→ Bit Manipulation
→ Recursion
→ Backtracking
→ Sorting Algorithms (Merge, Quick, Heap Sort)
→ Binary Search
→ Stack
→ Queue
→ Heaps
→ Binary Tree
→ Binary Search Tree
→ Graphs [Most IMP]
→ Dynamic Programming [Most IMP]
→ Trie

How To Prepare For Each Topic?

  1. Start with the implementation of the Data Structure or Algorithm. For eg: Learn how to implement binary tree or binary search at first.
  2. Then learn about various algorithms which are used in that Data Structure. For eg: Learn how to traverse a tree, DFS, BFS, etc.
  3. Solve all the common/generic/famous problems. For eg: If you are learning DP, then solve LIS, LCS type of problems.
  4. Then start solving the problems randomly.
  5. First choose easy problem. Solve 10–15 easy problems and once you get comfortable with easy problems, then move to medium and then to hard.

How to Solve a Problem?

I have created some mental models which will help you to solve a problem.

  1. DON’T FEAR ANY PROBLEM. Every problem which is given to you (by interviewer or some website) can be SOLVED.
  2. Clear your basics. You cannot solve a Graph problem, if you don’t have any idea about Graphs.
  3. Understand the problem fully. Don’t half read it, in fact read it twice or thrice.
  4. MOST IMP: Use Notebook while solving a problem.
  5. Dry run the test-cases. Just know how the answer to a test-case is forming.
  6. Try to figure out the topic on that problem. Figure out which Data Structure(s) or Algorithm(s) can be used.
  7. Break down the problem into smaller sub-problems.
  8. If the problem is based on observation, then check if you can find some pattern. For eg: check for n = 0,1,2,3, and so on till you find some pattern.
  9. Always try to use fundamental concepts to solve a problem. Most of the problems are built on top of some fundamental problem(s) only.
  10. Try to come up with the Brute Force approach and then try to optimize it.

Note: These are not steps, these are just some tips. But you can consider 1–6 as a step.

Detailed Guide On Problem Solving.

How much time to give to each problem?

NOTE: If you are a beginner then please don’t follow this timing because you’ll have to give an hour or two even to solve an easy problem. So take your time as a beginner.

These are the timings which I generally follow.

→ Easy Problems: 15 –20 mins
→ Medium Problems: 30–45 mins
→ Hard Problems: 1–1.5 hours

And if you still cannot figure out the solution after that, then it is better to look at the solution.

This is my timing which I follow, but don’t stick to this if the timing doesn’t suits you. In fact, I would encourage you to create your own timing.

Websites

Hackerank (for beginners)
Leetcode
Geeks For Geeks
InterviewBit
Hackerearth

YouTube Channels

Take U Forward
Code Help — By Babbar
PepCoding
MIT- Introduction To Algorithms
Aditya Verma [For DP]
Anuj Bhaiya
NeetCode [For Leetcode Solutions]
TechDose [For Leetcode Solutions]
Abdul Bari

Competitive Programming

Competitive Programming is a mind sport in which some problems are given and you compete with others by solving those problems as fast as you can.

If you are very much interested towards DSA then after having some hands-on knowledge of DSA, I would suggest you to do Competitive Programming (on CodeForces, CodeChef, etc).

But if you are more interested towards Development, then I would suggest that along with Development try to give at least one Leetcode Contest every week.

The benefit of competitive programming is that, you can think and code fast. Plus your confidence increases in problem solving.

Conclusion

Now, coming back to the first question which you asked. How you can solve 2000+ problems?

Well the simple answer to question is “you don’t have to”.

When I started DSA, my goal was never to solve 2000+ problems. My goal was just to solve a particular problem which is given to me. And this is the best way to solve more problems. Don’t have any goals in problem solving. Just keep on solving and level up.

Last but not least, don’t focus on quantity, focus more on the quality. Even if you solve 1 problem in a day, but solve that problem in such a way that you know ins and outs of that problem.

About Me

I am Tushar, a software engineer at Cisco. I started my journey back in 2020. With a tier-3 college tag and Non-CS branch I managed to get into tech after working on my skills for more than 2 years.

DM’s always open on Twitter & LinkedIn.

Best Luck For Your Journey :)

--

--