The codes provided in this repository are written based on my personal preferences. Although they are public, I continue to use this repository for participating in contests. Therefore, please ensure that you take appropriate measures to protect your code against plagiarism.
Contests for Newcomers |
---|
Contest 1 |
DSA and Interview Preparation |
---|
LeetCode |
GeeksForGeeks |
InterviewBit |
CodingNinjas |
Binary Search (currently down) |
Useful resources for learning |
---|
Good Tutorials for Competitive Programming |
EKZLib |
Handy tools for contests |
---|
Graph Editor - CSAcademy |
OEIS - The On-Line Encyclopedia of Integer Sequences |
- AtCoder Standings
- Codeforces Contest List
- Virtual Judge
- Codeforces Profile Comparator
- USACO Contests Guide
- Codeforces Recommender by CodeDrills
- Codeforces - C++ Tricks
- Codeforces - Useful C++ Tricks
- Codeforces - C++ Optimization Techniques
- Codeforces - Cool C++ Features
- C++ Reference - cppreference.com
- LearnCpp.com - C++ Tutorial
-
Pay Attention to Problem Statement: Take extra care to read the problem statement correctly. Mistakes in understanding the problem can lead to wrong solutions. For example, distinguishing between "undirectional" and "unidirectional" graphs (undirected vs directed) can significantly impact the approach.
-
Analyze the Constraints: Understanding the problem constraints can provide valuable insights into choosing the appropriate algorithms and data structures to solve the problem effectively.
- Om Ashish Soni's Competitive Programming Repository
- KTH Competitive Programming Repository
- USACO Implementations by Benjamin Qi
- VisuAlgo - Visualizing Algorithms and Data Structures
- Topcoder Data Science Tutorials
- CS97SI - Introduction to Competitive Programming from Stanford University
- Codeforces Problemset
- AtCoder Contest Archive
- Saraswati Online Judge
- CodeChef
- HackerRank Dashboard
- CSAcademy Contest Archive
- TLX - Toki Learning Center
- Kattis Open
- USACO Guide - Practicing
- Codeforces - Guide to Problem Solving
- Informatics Notes - Preparing for Contests
- Programming and Problem Solving (PAPS) by USACO Guide
- Competitive Programming Handbook (CPH) by USACO Guide
- Competitive Programming in C++ by Darren Yao
- Practice on Codeforces: Solve a lot of problems on Codeforces that are just above your current rating range.
- Prioritize Codeforces: Codeforces is the best platform to improve your competitive programming skills, so spend a significant amount of time on it.
- AtCoder: Participate in AtCoder Beginner Contests, which are suitable for beginners and provide valuable practice. You can also try AtCoder Regular Contests.
- Codechef: Use Codechef for math and bit manipulation questions.
- Codechef Starters Contests: Participating in Codechef Starters Contests can be beneficial.
- LeetCode: Solve LeetCode Weekly and Biweekly Contests for practice and warm-up. These contests often have a mix of easy and medium difficulty questions, which can boost your motivation.
- Awesome Resources: Explore the following resources for inspiration and motivation:
-
Stuck in a Contest: If you feel stuck during a contest, take a short break of 1 or 2 minutes. Wash your face to refresh yourself and then start again with a clear mind.
-
Can't Improve: If you're struggling to improve, try upsolving. If you can't come up with any ideas, refer to the editorial. If there is an unfamiliar topic, learn it and repeat this process.
-
How to Boost Performance: Participating in long challenges on Codechef can help boost your performance and allow you to learn various tips and techniques.
-
Combining Different Approaches to Solve Problems: When faced with a problem, try multiple approaches. For example, if it's a graph problem, start with DFS. If that's not enough, try using disjoint sets. If there's a need for path compression, use it. If the constraints allow, consider using Fenwick trees. This approach helps you combine different techniques to solve problems effectively.
-
Difficulty with Last 3 to 4 Problems of a Contest: If your basics are clear, practice a lot of problems related to trees, graphs, dynamic programming, and segment trees until you feel satisfied.
-
Where and How to Practice:
- Hackerrank is a good platform for beginners to learn a programming language.
- Once you have a basic grip on a language, move to the problem set on Codeforces.
- Solve problems on Codeforces with ratings below 1000.
- Practice problems based on specific topics from the Codeforces problem set.
- Participate in contests on Codeforces and Codechef.
- Upsolve problems. If you can't solve a problem within 30 minutes, refer to the editorial. Learn any unfamiliar topics and repeat this process.
- As your rating improves, continue step 4 and solve problems within the rating range of [your rating - 100, your rating + 100].
- Keep learning new algorithms and practice implementing them.
-
How Problem Setters Find New Problems: Not all problems in contests are built from scratch. Many problems are a mixture of multiple problems from resources like the CSES Problem Set.
-
Getting TLE with String as a Key in Ordered Map: If you're experiencing performance issues with a string as a key in an ordered map, try using a hash map instead. This change may improve the performance.
-
IDE Recommendation: In competitive programming, it's recommended not to use an IDE. Instead, develop a habit of using a text editor like Vim.
-
Which Template Should I Use in CP?: There are various templates available for competitive programming. You can refer to the following resource for templates that are useful in competitive coding: Templates Useful for CP
-
Tips to solve Constuctive :
- Writing a brute force script rather than manual solving
- Finding a pattern
- coding optimized solution corresponding to pattern
- Taking care of edge cases.
Here's an implementation of the Ruffle Sort algorithm inspired by code from the second thread:
static void ruffleSort(int[] a) {
int n = a.length; // Shuffle, then sort
for (int i = 0; i < n; i++) {
int oi = random.nextInt(n);
int temp = a[oi];
a[oi] = a[i];
a[i] = temp;
}
Arrays.sort(a);
}
- start with array -> practice -> 2 π
- learn c++ stl or any language similar library, dp -> 3 π
- disjoint set union , graph, little dsa -> 4 π
- segment tree -> 5 π
- Codechef has very nice problems on Bit manipulation So , making good grip over bit manip can help in contest.
- Codeforces requires speed of solving problems.
- Even if you solve only 2-3 problems , but very quickly then , you will get fruitful ratings.
- Upsolving is required since the problem pattern might be repeated in future problems.
- First two questions are mostly greedy in div -2,3,4 contests. No prior knowledge except programming language is required.
- Below is example how upsolving looks like
If you encounter the error "Source should satisfy regex [^{}]public\s+(final)?\sclass\s+(\w+)" while using Java on Codeforces, follow this guide to resolve the issue: Troubleshooting Java Error on Codeforces
You can easily jump by 2 in Python using the range()
function with a step size of 2. Here's an example:
for i in range(0, 10, 2):
print(i)
Discover a lesser-known resource that can enhance your competitive programming skills: Heap using STL in C++
To avoid recursion depth problems in Python, you can increase the recursion limit using the following code:
import sys
sys.setrecursionlimit(10**6)
Explore a collection of useful C++ tricks to enhance your programming efficiency: C++ Tricks on Codeforces
Feel free to explore these resources to overcome common challenges and improve your competitive programming skills.
Welcome to the repository! This README file provides important information and resources related to the project.
You can find the roadmap . It outlines the planned features, milestones, and overall direction of the project.
For additional information and insights, you can refer to the Codeforces blogs . These blogs cover various topics related to competitive programming and can be a valuable resource for learning and improving your skills.
Please keep in mind the following points:
- Number theory, bit manipulation, and dynamic programming (DP) are among the most popular topics in competitive programming.
- In 98% of the contests, at least one of these topics is always included.
- It is essential to practice these topics extensively to improve your proficiency.
N | Big O |
---|---|
For N <= 10 | O(2^N) and O(N!) |
For N <= 100 | O(N^3) |
For N <= 10^3 | O(N^2) |
For N <= 10^5 | O(NLogN) |
For N <= 10^6 | O(N) |
For N <= 10^9 | O(logN) |
channel |
---|
Tushar Roy |
Striver |
CodeNCode |
Tech-Dose |
Luv |
Apna college Placement course |
Errichto |
William Lin |
William Fiset |
Algorithms live |
benritmicocode |
jonathan paulson |
Second Thread |
Topic Reference Link |
---|
Dynamic Programming Video |
Mathematics for DSA & CP Video |
Article Reference Link |
---|
Roadmap for Competitive Programming |
Modulo Multiplicative Inverse |
Random Shuffle |
- At maximum, a number can have O(2*sqrt(n)-1) factors, which is the upper bound for the number of factors.
- A leaf node is a node with a degree less than or equal to 1.
Please refer to the respective links for more information and resources related to coding, competitive programming, and problem-solving.
To configure Vim for competitive programming, follow the steps below:
- Open the terminal and enter the command:
vi ~/.vimrc
- Paste the following configuration code into the file:
set number
set tabstop=4
set shiftwidth=4
set autoindent
set mouse=a
colorscheme default
autocmd vimEnter *.cpp map ^B :w <CR> :!clear ; g++ --std=c++17 %;if[[-f Output : ++++++++++++++++++++++++++++++++] a.out ];time ./a.out; rm a.out; if[[-f End : --------------------------------]a.out]<CR>
- Press
Ctrl+C
and thenCtrl+B
to compile and run the code.