# Getting started with competitive coding

This is a question that has haunted me for years, and I could never begin for a long time. Finally, it turned out to be a simple lesson: “start by doing”, and that’s all that is required. The only problem in this statement is what exactly to start with.

# Step 1

## A. Programming Language

The first step is to choose a programming language (only choosing and not mastering). Once you choose a programming language, you only need to know some basic functionalities and shouldn’t really bother about mastering the language at this point. Many people (including me) fall in this trap of thinking that they should first master the programming language and then start coding.

Two of the best programming languages known for competitive programming are C and C++. I would recommend C++ here. Both of them take less time of execution than Python but one cannot deny how C++ STL makes your life easier.

## B. Practice

So, to learn the required basic functionalities, head to the HackerRank and login/create your account. Start your journey by solving basic problems like how to find a prime number, the number of factors of a number, factorial of a number, find greatest/lowest among array, insert an integer into an array, string operations using ASCII values, the sum of the digits of a number, etc. You can find a bunch of such problems on SPOJ.

You might not realize the worth of solving these problems but practicing these more frequently could help you shorten the code than earlier which you used to right and help you save time. Additionally, you will learn how to write error-free code.

# Step 2

## A. Data Structures

Data Structures and Algorithms are going to be your biggest friends if you choose to make them! Not only in your Competitive Programming journey but also in your Placement Interviews. Data structures are the basic building blocks of competitive coding and to start, it is better to first read about basic data structures mentioned below.

- Array
- Linked List
- Stack
- Queue
- Strings
- Hashing* (Only usage, you can read theory later on)
- Binary Trees
- Binary Search Trees
- Heap

You can learn about above data structures from GeeksforGeeks. Read their theory and learn how to implement them in the programming language of your choice. GeeksforGeeks has links to implementation of these data structures in different programming languages on the respective theory pages.

## B. Practice

HackerRank? CodeChef? HackerEarth? Practice is highly important to understand the types of problems. Also, practice improves your question reading skills which can help you save time. Mathematics is super fun and you’ll be amazed to know how mathematical functions can be used to find solutions to such complex scenario problems.

As you finish the warm-up problems move on to implementations, strings, sorting, search, recursions, debugging and several other sections that’ll help you master the art of solving problems.

The best part about these platforms is they not only help you prepare but also enhances the spirit of competition, the spirit of winning. One just cannot express the feeling of satisfaction when you get solving problems. The feeling which you get achieving the Gold badge is amazing! Nobody can take it from you, it’s yours! Start with basic data Structures problems in Hacker Rank and Hacker Earth.

# Step 3

## Algorithms

Algorithms are the most important part of competitive programming and if you master algorithms, you are more than 50% done.

MIT has many courses on Algorithms, and you may find it very overwhelming to complete all of them. Also, it is not required to complete all of them for fresher coding tests. So I am mentioning selective lectures from the courses MIT 6.006 Introduction to Algorithms, Fall 2011 and MIT 6.046J Design and Analysis of Algorithms, Spring 2015 that you can watch in the sequence mentioned below:

- [MIT 6.006] R1. Asymptotic Complexity, Peak Finding
- [MIT 6.006] R5. Recursion Trees, Binary Search Trees (only Recursion trees part)
- [MIT 6.006] Lec1: Algorithmic Thinking, Peak Finding
- [MIT 6.006] Lec2: Models of Computation, Document Distance
- Read about Recursive Thinking from GeeksforGeeks
- [MIT 6.006] Lec3: Insertion Sort, Merge Sort
- [MIT 6.006] Lec4: Heaps and Heap Sort
- [MIT 6.006] Lec5: Binary Search Trees, BST Sort
- [MIT 6.006] Lec7: Counting Sort, Radix Sort, Lower Bounds for Sorting
- [MIT 6.046J] Lec2. Divide & Conquer: Convex Hull, Median Finding
- [MIT 6.046J] R1. Matrix Multiplication and the Master Theorem (matrix multiplication is optional, but do check master theorem)
- [MIT 6.046J] R4. Randomized Select and Randomized Quicksort

Above lectures should be enough to start with coding online (and this is the aim here: **to start practicing at earliest**).

# Step 4

## Online Coding

Practice must never stop! Practice! Practice! Practice!

Even if you don’t get time, make it to just 5–7 problems a day. Learn about more algorithms like Greedy, Dynamic Programming, Backtracking, etc. And don’t forget to revise Data Structures and Algorithms regularly. There are several websites to practice coding like LeetCode, HackerRank, InterviewBit, Codeforces, CodeChef etc. I haven’t used the last two or any other website and have used only the first three. I would personally recommend to start with LeetCode (assuming that you have at least two semesters (8 months) to prepare else start with InterviewBit).

## Summary

That’s it. If you have come this far, you should have gained competitive coding skills. All the best for your placements/coding challenges! Thank You for reading and let me know in comments your experience in learning coding.