# Code your way through Competitive programming!

If you’re wondering how to be an ace programmer, then one of the best ways to do so is through competitive programming. Topcoder, Hackerearth, SPOJ, etc all must ring a bell, these are sites that provide high-quality problems to you that are a little difficult to crack. Competitive programming needs a slightly different approach than regular programming.

#### How is competitive programming different from normal programming?

I got this excerpt from a popular Quora answer which could answer it best:

This basically tells us that in developmental programming, we need to write an efficient code. However, competitive programming requires a code which “just works” with the given conditions.

#### So, what exactly do you need to “kill the lion” in 2 minutes?

• You need to know the basics of a language, pick any, C++ or Java, whichever you’re comfortable with.
• Pick an online judge. Some popular ones are: topcoderSPOJcodechef and hackerearth.
• Practice these problems thoroughly such that you earn around 240 points a day.

Sounds easy? Well, for those of you who have tried a hand at it must know that TERMS like TLE(Time limit exceed), MLE(memory level exceed) and WA(Wrong answer)  are so good at giving NIGHTMARES!

### How to be a Ninja Competitive programmer?

To gain crazy ninja skills at competitive programming, one needs to have a grasp of a few specific topics.

Topics mostly covered in contests are:

1. Graph algorithms: Breadth first search (BFS), Depth first search(DFS), Strongly connected components (SCC), Dijkstra, Floyd-Warshall, Minimum spanning tree(MST), and Topological sort.
2. Dynamic programming: Standard dynamic programming problems such as Rod Cutting, Knapsack, Matrix chain multiplication, etc
3. Number theory: Modular arithmetic, Fermat’s theorem, Chinese remainder theorem(CRT), Euclidean method for GCD, Logarithmic Exponentiation, Sieve of Eratosthenes, and Euler’s totient function
4. Greedy: Standard problems such as Activity selection
5. Search techniques: Binary search, Ternary search, and Meet in the middle
6. Data structures (Advanced): Trie, Segment trees, Fenwick tree or Binary indexed tree(BIT)