└── README.md /README.md: -------------------------------------------------------------------------------- 1 | # CP-WORKSHOP 2 | 3 | ## BASICS 4 | ### [Binary Exponentiation](https://cp-algorithms.com/algebra/binary-exp.html) 5 | ### [Greatest Common Divisor](https://cp-algorithms.com/algebra/euclid-algorithm.html) 6 | ### [Nth Fibonacci Number](https://www.geeksforgeeks.org/program-for-nth-fibonacci-number/) 7 | ### [Sieve of Eratosthenes](https://cp-algorithms.com/algebra/sieve-of-eratosthenes.html) 8 | ### [Integer Factorization](https://cp-algorithms.com/algebra/factorization.html) 9 | ### [Primality tests](https://cp-algorithms.com/algebra/primality_tests.html) 10 | ### Modular Arithmetic 11 | ```cpp 12 | // Addition 13 | (a + b) % m = ((a % m) + (b % m)) % m 14 | 15 | // Subraction 16 | (a - b) % m = ((a % m) - (b % m)) % m 17 | 18 | // Multiplication 19 | (a * b) % m = ((a % m) * (b % m)) % m 20 | 21 | // Division (We need to use Mod Inverse) 22 | (a / b) % m != ((a % m) / (b % m)) % m 23 | ``` 24 | ### [Modular Inverse](https://cp-algorithms.com/algebra/module-inverse.html) 25 | ```cpp 26 | // Using Fermat's Little theorem 27 | // If m is prime 28 | modInv(a, m) { 29 | return fastpow(a, m - 2, m); 30 | // pow(a, m - 2) % m 31 | } 32 | (a / b) % m = ((a % m) * modInv(b, m)) % m 33 | ``` 34 | 35 | ## TOPICS 36 | ### Binary Search 37 | * [Tutorial](https://www.topcoder.com/community/competitive-programming/tutorials/binary-search) (Topcoder) 38 | * [AGGRCOW](https://www.spoj.com/problems/AGGRCOW/) 39 | * [SNAKEEAT](https://www.codechef.com/problems/SNAKEEAT) 40 | 41 | ### Divide and Conquer 42 | * [Merge Sort](https://www.geeksforgeeks.org/merge-sort/) 43 | * [Inversion Count](https://www.geeksforgeeks.org/counting-inversions/) 44 | * [Count Subarrays with Neg Sum] 45 | * [TASTYD (Subproblem)](https://www.codechef.com/problems/TASTYD) 46 | 47 | ### Disjoint Set Union (DSU) 48 | * [Tutorial](https://www.hackerearth.com/practice/notes/disjoint-set-union-union-find/) (Hackerearth) 49 | * [Implementation](https://github.com/yash0530/CP/blob/master/01%20DSA/001%20DSU.cpp) 50 | * [DISHOWN](https://www.codechef.com/problems/DISHOWN) 51 | * [ABC 120D](https://atcoder.jp/contests/abc120/tasks/abc120_d) 52 | 53 | ### Tries 54 | * [Tutorial](https://www.hackerearth.com/practice/data-structures/advanced-data-structures/trie-keyword-tree/tutorial/) (Hackerearth) 55 | * [Implementation](https://github.com/yash0530/CP/blob/master/01%20DSA/016%20Trie.cpp) 56 | * [MAX-XOR](https://www.hackerrank.com/challenges/maximum-xor/problem) 57 | * [SHKSTR](https://www.codechef.com/JUNE18B/problems/SHKSTR) 58 | * [ENGLISH](https://www.codechef.com/problems/ENGLISH) 59 | 60 | ### Graphs 61 | * [TOPOSORT](https://www.spoj.com/problems/TOPOSORT/) (Topological Sort) 62 | * [BUGLIFE](https://www.spoj.com/problems/BUGLIFE/) (Bipartite Graph) 63 | 64 | ### String Hashing (Rolling Hashing) 65 | * [Tutorial](https://www.quora.com/q/threadsiiithyderabad/String-Hashing-for-competitive-programming) 66 | 67 | ## ADVANCED TOPICS 68 | ### Dynammic Programming 69 | * [Top 20 must do DP problems](https://www.geeksforgeeks.org/top-20-dynamic-programming-interview-questions/) (GFG) 70 | * [Educational DP contest](https://atcoder.jp/contests/dp/tasks) (AtCoder) 71 | * [EXPCAN](https://www.codechef.com/problems/EXPCAN) 72 | * [Burst Balloons](https://leetcode.com/problems/burst-balloons/) 73 | * [PEPPERA](https://www.codechef.com/COOK115A/problems/PEPPERA) 74 | * [ABC 158F](https://atcoder.jp/contests/abc158/tasks/abc158_f) 75 | 76 | ### Segment Tree 77 | * [Tutorial](https://cp-algorithms.com/data_structures/segment_tree.html) (cp-algorithms) 78 | * [Tutorial](https://kartikkukreja.wordpress.com/2014/11/09/a-simple-approach-to-segment-trees/) 79 | * [Tutorial](https://www.youtube.com/playlist?list=PLMCXHnjXnTnuASA1NghV3Vs9J3D_ij5w2) (Youtube) 80 | * [Implementation with Lazy Prop](https://github.com/yash0530/CP/blob/master/01%20DSA/004%20LAZY.cpp) 81 | * [ABC 157E](https://atcoder.jp/contests/abc157/tasks/abc157_e) 82 | * [FLIPCOIN](https://www.codechef.com/problems/FLIPCOIN) 83 | * [GSS1](https://www.spoj.com/problems/GSS1/) 84 | * [CYCLCSUM](https://www.codechef.com/COOK115A/problems/CYCLCSUM) 85 | 86 | ### Tree DP 87 | * [Tutorial](https://codeforces.com/blog/entry/20935) (Codeforces) 88 | 89 | ### Polynomial Multiplication (FFT) 90 | * [Tutorial](https://cp-algorithms.com/algebra/fft.html) (Don't worry too much about math behind it, learn how to use it) 91 | * [Codeforces 993E](https://codeforces.com/problemset/problem/993/E) 92 | 93 | 94 | ### LCA (Binary Lifting) 95 | * [Tutorial](https://www.youtube.com/watch?v=ctZ7fjMbPWE) (Youtube) 96 | * [Tutorial](https://cp-algorithms.com/graph/lca_binary_lifting.html) (cp-algorithms) 97 | 98 | ## RESOURCES 99 | 100 | ### Youtube 101 | * [ Learn Competitive Programming with CodeChef](https://www.youtube.com/channel/UCh-5M0r0SBgb5xNCFXG7aXQ) 102 | * [Colin Galen](https://www.youtube.com/channel/UCpvS3EykHW--l0ogUhMEjEw) 103 | * [SecondThread](https://www.youtube.com/channel/UCXbCohpE9IoVQUD2Ifg1d1g) 104 | * [Errichto](https://www.youtube.com/channel/UCBr_Fu6q9iHYQCh13jmpbrg) 105 | * [Gaurav Sen](https://www.youtube.com/channel/UCRPMAqdtSgd0Ipeef7iFsKw) 106 | * [William Lin](https://www.youtube.com/channel/UCKuDLsO0Wwef53qdHPjbU2Q) 107 | 108 | ### Contests and Practice 109 | * **[Codeforces](https://codeforces.com/)** 110 | * [Codechef](https://www.codechef.com/) 111 | * [InterviewBit](https://www.interviewbit.com/practice/) 112 | * [AtCoder Archives](https://kenkoooo.com/atcoder/#/table/) 113 | * [AtCoder](http://atcoder.jp/) 114 | * [LeetCode](https://leetcode.com/) 115 | * [SPOJ](https://spoj.com) 116 | 117 | ### Reading 118 | * Editorials on Codechef and Codeforces 119 | * [Book](https://cses.fi/book/book.pdf) 120 | * [cp-algorithms](http://cp-algorithms.com/) 121 | * [Codeforces Tutorials](https://codeforces.com/blog/entry/57282) 122 | * [Topcoder Tutorials](https://www.topcoder.com/community/competitive-programming/tutorials/) 123 | --------------------------------------------------------------------------------