cp-snippets

Here I have collated my implementations of most of the prominent data structures and algorithms I use for competitive programming. Note that these are catered to my specific tastes, but feel free to propose changes and additions. I will happy to incorporate them! They are classified based on the type of algo/ds as given below :

  • advance-ds.cpp - not-so-basic stuff which finds dynamic use in a wide range of questions like Fenwick tree, Sparse Matrix, Segment Tree (with lazy propagation), etc.
  • array.cpp - functions for permutations and inversion calculations.
  • bitmasks.cpp - guidelines and tricks for bitmask calculations. very useful for quick reference.
  • geometry.cpp - function for orientation between two general lines, and Graham Scan for convex hull.
  • maths.cpp - functions for binary exponentiation, GCD calculation, modulus operations, combinatorics calculations (such as using classical method, Luca's theorem etc), Sieve of Eratosthenes, mobius inversion and many more.
  • string.cpp - string functions like KMP, Z-function, Rabin-Karp hashing and Manacher.