Problem Solving Using Algorithms and Data Structures – Competitive Programming Part-2

If you missed the part-1 of the series, you can find it here.

This part will deal with the next step in your journey – starting to solve problems using data structures and algorithms.

There are many ways to do this. I have personally found going through a few things very apt in this process.

This part will give you a step by step guidance.

Once you have started learning algorithms and data structures, do it this way for the most effective experience.

Learn algorithms according to a category, like sorting, searching, stacks, queues, etc,.

Geeks For Geeks:

Once you learn the data structure/algorithms in a particular category, head over to Geeks For Geeks – Data Structure Problems. Solve all the problems in the category of data structures/algorithms that you have learned.

Say, you learn all about stacks, stack operations. You then head over to geeksforgeeks and solve all the problems listed under stack. Before seeing the solution given below the problem, try guessing the solution based on the knowledge you have gained about that particular data structure or algorithm. If you arrive at the solution, great! If you don’t arrive at the solution, go through the solution they have given, along with the time and space complexity of the solution.

Their solutions are in C++. So, if you take up java, it will be a real learning experience, writing the solution in java code rather than just copying the code. The way the data structures are written in java is different from what they have given in the geeksforgeeks site. So, it will be very well worth your time especially if you have taken up java as your preferred language of choice.

From stacks, queues, up until trees, you might find the geeksforgeeks problems a tad bit easier to solve and code. When you get into problems related to trees, graphs, there will be a huge difference between what they have coded in C++  and what you will do in java.

If you take up java, it will be advisable to go through the entire code archive of Princeton Algorithms 4th edition book. You will find the java code for every data structure and algorithm given in the book. What more, the code is very well optimized, written following the best practices, and added to that, the boundary conditions are very well taken care of. Even if you are going to write your own code, just taking a look at their code will be really helpful in giving you an idea of how it is all structured.


This is the website created by the author of “Cracking the coding interview” book – Gayle McDowell. This website has the most comprehensive list of programming interview questions – sorted by companies, categories, difficulty, designations, etc.

Head over there, and sort the problems based on categories – choose the category of problems you want to solve. Let’s say that you have learned about binary search trees and you want to solve problems which use binary search trees. All you need to do is, head over to the careercup problems page. In the filter area, select the category you need and click Go. Many problems are listed along with the answers from the users of the forum. You can also post your code, solved on, provide improvements on their answers, etc. This is one of the best programming questions related forum in the web. You will also find code of few many languages there, in the answers section where the users have posted their answers along with the code.


This is another relatively less known but very useful website for questions related to problem-solving using data structures and algorithms. This forum is a counterpart for the online judge of the same name. The problem set given in the online judge is also very helpful. You will find the tags of categories on the right side of the page which you can use to view only the problems of your desired category.

If you are specifically preparing for programming interviews and campus placements, these resources will be very helpful.

Further resources you can use to hone your problem-solving skills – learning problem-solving patterns, understanding the basics of problem-solving are given below.


1. Tech Interview
2. Quora Page for Programming Interviews


1. Cracking The Coding Interview
The best selling book that contain a comprehensive list of most frequently asked programming questions with solutions. A must read. Solve all the problems in this and you will be very confident acing any interview, solving any problem.

2. Elements Of Programming Interviews
This is another amazing book. Unlike the previous book, this book starts from the basics and helps you go through everything topic after topic in the order of increasing difficulty

3. Programming Interviews Exposed
4. Coding Interview Questions
These two are really good books that contain a lot of very useful programming questions. Karumanchi is a household name in India and his Data Structures and Algorithms Made Easy: Data Structure and Algorithmic Puzzles book makes for an amazing read and easy understanding. Many of my friends suggest this book. There is also a java version of the book from the same author – Data Structures and Algorithms Made Easy in Java: Data Structure and Algorithmic Puzzles

Going through all these resources one after the other is only for one goal. To become very good in solving problems using data structures and algorithms.

What happens when you go through this process is that, initially, with any category of data structure/algorithm, you will find that you can’t really come up with a solution. But, as you go through more problems of the same category and their solutions, you will train your brain to find patterns among various similar problems. So, once your brain is very well trained in a particular category, it will do amazingly well in coming up with solutions when you encounter a problem similar to the one you have solved in the past. That is how this entire thing works. So, to train your brain, you will have to practice a lot. Let’s say you take up the category of Stack related problems. You will have to do at least 20 to 30 problems in order to even begin to recognize the solution pattern among similar problems. The tougher the category, the more the number of problems you will need to solve in order to train your brain to identify similarity in problems and to come up with related, efficient solutions.


If you have any suggestions, and any improvements that you think I could do to this article, please do let me know in the comments section below. I will make sure I’ll include your input in this post. I want this series to be helpful to as many people as possible and I have written it in a way that seemed the best fit. If you think that this can be improved, probably some more resources and some more steps can be added to the guidance – I’d be happy to take your inputs and include them where they fit in.

Also, you can check out the Part – 3 of the series.



Loading Facebook Comments ...

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>