Complete guide to kick-off Competitive Programming!

Dhruv Kothari
GDSC DYPCOE
Published in
5 min readMar 19, 2020
Photo by Kari Shea on Unsplash

Note from Author(Dhruv Kothari):- Hello readers! This article is based on the beginner-friendly approach to competitive programming. All the opinions expressed in this article represent my own views which I think is appropriate for a newbie in the world of competitive programming.

A competitive person is always a winner. An uncompetitive person is always a loser.

~Dr. T. P. Chia

What is Competitive Programming?

According to me, competitive programming is a sport. A sport based on problem-solving skills, thinking ability, speed testing, regularity and to be precise. Competitive Programming will help you building logic and implementing that logic to find solutions to a real-world problem. Brainstorming upon your code will definitely increase your coding skills as well as it will help to expand your thinking capacity. Thus practising Competitive Programming on day to day basis help you in mastering that particular language. And believe me, if you are playing this sport regularly, you are already prepared for the technical rounds of the Interviews. So now lets dive in the ocean of Competitive Programming.

How to start competitive programming?

Frankly, there is no particular right time to start doing this but it is advised to start as early as possible. We all have heard a great saying that — Early bird catches the worm. Right? Therefore it's never too late to do this but you should start the moment you get to know about it.

Just Begin. Take your laptop, a pen, and a book. Get a problem statement, start thinking about the logic, build the algorithm and then finally implement it.

Now, we all know that we live in the era of the internet which brings us a lot of learning opportunities free of cost. So what we are waiting for, let’s utilize these opportunities. There are some amazing platforms for competitive programming through which a beginner can kick-off his/her journey.

Photo by Max Duzij on Unsplash

Hackerrank

According to me, this is one of the best platforms for a beginner to kick-off. It’s UI is simple and user-friendly. There are different categories like problem-solving and algorithms, mathematics, statistics, language proficiency(C, C++, JAVA, Python), SQL and many more. The questions range from EASY to HARD to ADVANCED. Lastly, you are gifted with star badges which really motivates you to do more.

Codechef

After spending a few days on Hackerrank and achieving a few golden badges, you can start with CodeChef. Problem Statements are of higher-order thinking than Hackerrank but if you are aiming to ace competitions like ACM-ICPC then this is one of the best platforms for practising. Codechef organizes contests like Monthly Long Challenges, Cook-off, and Lunch-time which show you your ranking/position nationally as well as globally so that you get to know where you currently stand globally.

Here is the list of few more platforms for practising ( for intermediate level and above ):-

  1. SPOJ (Sphere Online Judge)
  2. CodeForces
  3. TopCoder
  4. LeetCode
  5. Project Euler
  6. GeeksForGeeks
  7. HackerEarth

Knowledge is of no value unless you put it into practice.

Most important things a beginner should keep in Mind!

  1. Always read Constraints -Every problem-statement consists of a question-statement, Function-Description, Input-Output Formats, and most important constraints. They play a vital role in your code. Data types are chosen on the basis of constraints provided.

For e.g. talking about C++,

if constraints are like (0 ≤ arr[i] ≤ 10¹⁰) for this you can’t use normal int data-type. Here you have to go for long long int data-type.

2. Don't write any additional code- Stick to the input format and don’t write any additional line in the code. For eg- avoid writing in the traditional/inappropriate format like Enter the number of elements in the array ”and The Output of the code is.”

3. Persistence is always gigantic than performance- Focus more on practice instead of expecting results on the very first day. “Wait! even Miracles take a little time.” So just be consistent, try to do at least 5 questions every day and spend a good amount of time in each question. Don’t give up easily. PUSH YOUR LIMITS and KEEP PATIENCE.

4. Analyze your code on the basis of time and space complexities- As a competitive coder its very important to know the time and space complexity of your code. Because your code is judged on these parameters and hence you can improve your code by reducing these complexities.

5. Data Structures and algorithms: stalwarts of coding. Without having proper knowledge of DS-A one can’t go far in this journey. Keep a habit of learning new algorithms and techniques regularly and try to implement these algorithms while solving the problem statements. It will help you creating codes with reduced code complexions w.r.t time and space.

Tips and Suggestions:-

  1. Don’t revolve around multiple languages. Stick to one language like C++ or JAVA or Python etc. In my opinion, I would recommend C++ over any other language because of its simple syntax and faster speed.
  2. Debug your code. It is very important to find mistakes in your own code so that mistakes can be avoided for next time.
  3. Analyze other’s code. Generally, it's a good practice to analyze other people's code. For eg: While doing problems on Hackerrank after completing a problem just go to Discussions and read other people’s solutions which will give you better and unique ideas of doing the same question.
  4. Learn New Things. Read about different coding styles and techniques like recursion, backtracking, dynamic programming and many more.
  5. And finally, LOVE YOUR CODE. I don’t think there is any need to explain it further xD. Right!

So What are you waiting for…just go and code !!!

Thanks for being with me until here. Here is a bonus point for you!

To visualize and debug there is a terrific website that provides live visualizing so that you can track and visualize each and every line of your code. This is really a very handy tool for a beginner as he can know the working of his code.

Few must-read Articles:-

Photo by Ashkan Forouzani on Unsplash

So, at last, I would like to conclude by saying that persistence leads to miracles. Hence the practice, practice, and practice and last but not the least guide and motivate others to dive into the deep ocean of COMPETITIVE PROGRAMMING!

THANKS!

--

--