# Competitive Programming – A Complete Guide

Competitive Programming is a mental sport which enables you to code a given problem under provided constraints. The purpose of this article is to guide every individual possessing a desire to excel in this sport. This article provides a detailed syllabus for Competitive Programming designed by industry experts to boost the preparation of the readers.

**Topic:**

**What is Competitive Programming and How to Prepare for It?****Fast I/O:****CPP****,****Java****,****Python****Useful libraries:****CPP****,****Java****,****Python****Input/Output Files:****Set 1****,****Set 2****Tips and Tricks:****Set 1****,****Set 2****Input Methods:****CPP****,****Java****,****Python****Template:****CPP****Language:****CPP****,****Java****,****Python****Time Complexity:****Analysis****Setting up Competitive Programming Environment:****Sublime: CPP****,****Visual Studio: CPP and Python**

Basics, Greedy and Bit Manipulation

**Reverse an array****Problem 1****,****Problem 2**)**Sum of Digits****Program to Check if a Given String is Palindrome in C****,****Python**(Related**Problem**)**Sum of array elements****Problem**)**Maximum and Minimum element of array****Problem**)**Counting frequencies of array elements****Problem 1****,****Problem 2**)**Float and Precision:****CPP****,****Java****,****Python****Prefix sum****,****2D Prefix Sum****Difference Array | Range update query in O(1)****:**(Related Problems:**Problem 1****,****Problem 2**)**Coordinate Compression****:**(Related**Problem**)**Kadane Algorithm****:**(Related**Problem**)**Activity Selection Problem**: (Related**Problem**)**Job Sequencing Problem**: (Related**Problem**)**Sliding Window****:**(Related**Problem**)**Logical Operators:****CPP Set 1****,****Set 2****,****Java****,****Python****Bit Manipulation:****Set 1****,****Set 2****,****Set 3****Problem 1****,****Problem 2****,****Problem 3**)**Bitset CPP**

Number Theory and Combinatorics

**Prime Number****Problem**)**Sieve of Eratosthenes****Problem**)**Segmented Sieve**(Related**Problem**)**Find all divisors of a natural number**(Related**Problem**)**Least prime factor of numbers upto N**(Related**Problem**)**All prime factors of a number****Problem**)**Prime Factorization using Sieve O(log n) for multiple queries****Sum of all factors of a number****Problem**)**Gcd of Two numbers****,****Lcm of two numbers****Problem**)**Linear Diophantine Equations****Euclidean algorithms (Basic and Extended)****Euler’s Totient Function****Problem**)**Euler’s Totient function for all numbers smaller than or equal to n****Inclusion Exclusion Principle****Pigeon Hole Principle****Modular Operations****Modular Inverse****:**(Related**Problem 1****,****Problem 2**)**Chinese Remainder Theorem:****Set 1****,****Set 2****Power(x, y) in O( logN )****Power(x, y) % mod****:**(Related**Problem 1****,****Problem 2**)**Matrix Exponentiation****:**(Related**Problem**)**Permutation and Combination:****Set 1****,****Set 2****,****Quiz 1****,****Quiz 2****nCr:****Set 1****,****Set 2****nCr % mod:****Set1****,****Set 2****:**(Related**Problem**)**nCr % mod for multiple queries****:**(Related**Problem**)**Catalan numbers****:****Applications**and Related**Problem****Gaussian Elimination**

Searching, Sorting and Basic Data Structures

**Linear Search****Problem 1****,****Problem 2**)**Binary Search****,****Unbounded Binary Search****Problem 1****,****Problem 2****,****Problem 3**)**Inbuilt sorting O(logN):****CPP****,****Java****,****Python****Problem 1****,****Problem 2****,****Problem 3****,****Problem 4**)**Merge Sort****Problem 1****,****Problem 2**)**Quick Sort****Problem**)**Stack:**Implementation in**CPP****,****Java****,****Python****Problem 1****,****Problem 2****,****Problem 3**)**Queue:**Implementation in**CPP****,****Java****,****Python****Problem 1****,****Problem 2****,****Problem 3**)**Deque:**Implementation in**CPP****,****Java****,****Python****Problem**)**Priority Queue:**Implementation in**CPP****,****Java****,****Python****Problem 1****,****Problem 2****,****Problem 3**)

**Tree BFS****,****Tree DFS**(Related Problems :**Problem 1****,****Problem 2****,****Problem 3**)**Graph BFS****,****Graph BFS 2**,**Graph DFS**(Related Problems :**Problem 1****,****Problem 2**)**Dijkstra’s Shortest Path Algorithm****Problem****1****,****Problem 2**)**Bellman – Ford Algorithm****Problem**)**Floyd Warshall Algorithm****Problem**)**0-1 BFS****,****Dial’s Algorithm****Detect cycle:****Directed****,****Undirected****Problem 1****,****Problem 2**)**Disjoint set(union-find):****Set 1****,****Set 2****,****Set 3****Problem**)**Topological Sorting****,****Kahn’s Algorithm****Problem**)**Minimum Spanning Tree:****Prim’s Algorithm****,****Kruskal Algorithm****Problem**)**Bipartite or not****,****M-Coloring****Problem 1****,****Problem 2****,****Problem 3**)**Strongly Connected Components:****Tarjan****,****Kosaraju****Problem 1****,****Problem 2**)**Euler Path:****Undirected****,****Directed****Problem**)**Flow Algorithms:****Set 1****,****Set 2****,****Dinic’s Algorithm****Problem 1****,****Problem 2**)**Diameter of Tree****Centroid Decomposition****Lowest Common Ancestor**

Recursion and Dynamic Programming

**Recursion****:****Quiz 1****,****Quiz 2****,****Quiz 3****,****Quiz 4****,****Quiz 5****,****Quiz 6****,****Quiz 7****(**Related Problems :**Problem 1****,****Problem 2****,****Problem 3**)**Backtracking****: (**Related Problems :**Probem 1****,****Problem 2****)****Dp Introduction:****Set 1****,****Set 2****,****Set 3****,****Set 4****,****Set 5****Most useful Dynamic Programming questions****Additional DP Problems :****Problem 1****,****Problem 2****,****Problem 3****,****Problem 4****Dp on Trees:****Set 1****,****Set 2****Dp on Bit Masking:****Set 1****,****Set 2****,****Set 3****Digit Dp**

**Suffix Tree:****Set 1****,****Set 2****Z Algorithm****KMP Algorithm****,****Rabin-Karp Algorithm****Problem**)**Manacher’s Algorithm:****Set 1****,****Set 2****,****Set 3****,****Set 4****Suffix Automation:****Set 1****,****Set 2**

**Closest Pair of Points****How to check if two given line segments intersect?****(**Related**Problem**)**How to check if a given point lies inside or outside a polygon?****Convex Hull:****Set 1****,****Set 2****(**Related**Problem**)**Given n line segments, find if any two segments intersect****Check whether a given point lies inside a triangle or not****How to check if given four points form a square****: (**Related**Problem**)**Combinatorial Game Theory:****Set 1****,****Set 2****,****Set 3****,****Set 4****Minimax Algorithm in Game Theory:****Set 1****,****Set 2****,****Set 3****,****Set 4****,****Set 5****Variation in Nim Game****Find the winner in nim-game****Optimal Strategy for a Game**

**Trie:****Set 1****,****Set 2****,****Set 3****, (**Related Problems**:****Problem 1****,****Problem 2****,****Problem 3****,****Problem 4****,****Problem 5**)**Fenwick Tree:****Set 1****,****Set 2****,****Set 3****,****Set 4****, (**Related**Problem****)****Segment Tree:****Set 1****,****Set 2****,****Set 3****(**Related**Problem****)****Sparse Table:****Set 1****,****Set 2****Sqrt Decomposition:****Set 1****,****Set 2****Heavy Light Decomposition:****Set 1****,****Set 2****Meet in the Middle****MO’s Algorithm****,****Problem****Policy based Data Structure**

You may also check Geeksforgeeks Online Courses to Learn Data Structures and Algorithms, well designed courses taught by Industry Experts.

### Geeksforgeeks Courses:

**1. Language Foundation Courses [C++ / JAVA / Python ]**

Learn any programming language from scratch and understand all its fundamentals concepts for a strong programming foundation in the easiest possible manner with help of GeeksforGeeks Language Foundation Courses – Java Foundation | Python Foundation | C++ Foundation

**2. Geeks Classes Live**

Get interview-centric live online classes on Data Structure and Algorithms from any geographical location to learn and master DSA concepts for enhancing your problem-solving & programming skills and to crack the interview of any product-based company – Geeks Classes: Live Session

**3. ****Complete Interview Preparation**

Get fulfilled all your interview preparation needs at a single place with the *Complete Interview Preparation Course *that provides you all the required stuff to prepare for any product-based, service-based, or start-up company at the most affordable prices.

**4. DSA Self Paced**

Start learning Data Structures and Algorithms to prepare for the interviews of top IT giants like Microsoft, Amazon, Adobe, etc. with

*DSA Self-Paced Course*where you will get to learn and master DSA from basic to advanced level and that too at your own pace and convenience.

**5. Company Specific Courses – Amazon, Microsoft, TCS & Wipro**

Crack the interview of any product-based giant company by specifically preparing with the questions that these companies usually ask in their coding interview round. Refer GeeksforGeeks Company Specific Courses: Amazon SDE Test Series, etc.