Rajan Kumar

rajan

Founder & Programmer at HackersFriend Updated Nov. 16, 2019, 12:56 p.m. ⋅ 107 views

Step by step guide to improve competitive programming skills


Competitive programming is art of understanding and problem solving. Machine Learning or Blockchain might be the next big thing, but competitive programming problem-solving is the skill of the decade. It requires sharp analytical skill and expertise coding language too.

There are a lot of programmers out there, stuck on a stage where they are able to solve basic problems and ad-hoc problem, they find it difficult to skill up to solve hard problems. In this article, i have tried to provide a step by step guide to becoming good at competitive programming.

Step 1: Don't be trapped on Breadth

Well, We all have that one friend who has solved hundreds of coding problems. They love to wear it as a badge of honor. But when it comes to contests and competitive programming, they fail miserably. This is a very common scenario. It’s what we call the “Breadth-Only” approach. The problem is, 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. Competitive programming contests require deep problem-solving knowledge and the ability to code fast and accurately. You only develop these skills with focused practice.

Here’s a counter-intuitive approach that works better:

Focus on quality of problems, not the number of problems

This is comforting, right? Who wants to focus on several hundreds of 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:

  • You can code it quickly
  • You can code it with correct syntax, which means you are good at the language
  • You can write clean code in one go, because it’s second nature to you
  • You can apply the same code to a new problem quickly 
  • 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: Make a list of targeted problems

Identify a list of around 100 good quality problems. Many coding sites give you this. You can go there and make a list for yourself. Now, once you have this list note it down and let's get back to work.

 

Step 3: Master the data structures

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. Recommended language for competitive programming is C++. It gives you the required speed and felxibilty. But, you are free to choose the language of your taste.

Here is the important one, learn how to implement them. Yes, implement them by hand. Many people ignore this, but it’s extremely important. Many problems requires modify data structures or re-engineer them for a specific use case. To utilize them fully, you need to know how they work.

Here’s an 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.

To give you a note, here is a list of data structures, you need to master anyhow:

  1. Arrays and Lists
  2. 2D Arrays
  3. Strings
  4. Linked List
  5. Stack
  6. Queue
  7. Hash Table & Hash Set
  8. Heap
  9. Graphs
  10. Binary Tree
  11. Binary Search Tree
  12. Trie

How to do it? You need to divide your core problems are 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. Many coding sites also allows you to practice on problems specific to a data structure.

Step 4: Do Repeat what you learned

Alright. You made a list of questions and you started solving them. In order to add them into your regular mind, so that you can recall and utilize whenever a problem comes up, you need to keep solving problems reguarly after certain interval.

After a few weeks of this repeated practice, these newly aquired skills will be added to your practice and you'll be able to implement them whenever needed.

Step 5: Make your own library 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. After this, You can isolate the Binary Search code and practice it over and over. You know it will be used in similar problems. 

Similarly, there are several algorithms and data structures for which you can create your own library and use them whenever needed. You'll be able to identify which Data structure or algorithm to use after seeing the problem and you can quickly save a lot of time by using your library.

Step 6: Now, it’s time to focus on numbers

After you have aqired all the basics, made your library and comfortable to solve problems. You can start tartegting actual contest problems, and this is stage where you can solve as many problems you like is better.

Solving problems, will give you a lot of experience and you can improve your knowledge.

Last point: Practice on paper

Take a piece of paper and pen and try to solve problems, first on paper rather jumping to code directly.

Desiging solution on paper enforces your thinking and you get the habit of planning before coding. This is very important for competitive programming.

 

Congratulations! You sucessfuly lifted up your competitve programming skills. Happy coding. Do let me know how much this article helped you and what your apprach for improvements.

 



arrow_upward Upvote

comment Comment

arrow_downward downvote



Go back to feed

HackersFriend Updates





View more


Events


Nov. 28, 2018, 5:30 p.m.

Python from zero to hero

place Delhi

View details


Aug. 13, 2018, 5:30 p.m.

Python from zero to hero

place Bangalore ( HackersFriend office BTM Layout)

View details