Welcome!
Here you will find the C++ and Python implementations of algorithms and data structures I use for competitive programming and interviews, plus my contest templates. They come from my notebook, where each one has unit tests, and the blog explains many of the ideas behind them.
-
Templates
Contest Template
contest.cppView -
Templates
LeetCode Template
leetcode.cppleetcode.pyView -
Templates
Minimal Template
minimal.cppView -
Templates
OI Template (file I/O)
oi.cppView -
Templates
Python Contest Template
template.pyView -
Arrays · monotonic stack
Monotonic Stack
MonotonicStack.pyView -
Arrays · prefix sums
Prefix Sum
PrefixSum.pyView -
Arrays · sliding window
Sliding Window
SlidingWindow.pyView -
Searching · backtracking
Backtracking
Backtracking.pyView -
Searching · binary search
Binary Search
BinarySearch.pyView -
Data Structures · compression
Compressed Sparse Row
CSR.hCSR.pyView -
Data Structures · range queries
Fenwick Tree
FenwickTree.hFenwickTree.pyView -
Data Structures · range queries
Iterative Segment Tree
IterativeSegmentTree.hIterativeSegmentTree.pyView -
Data Structures · range update, range query
Lazy Segment Tree
LazySegmentTree.hLazySegmentTree.pyView -
Data Structures · range queries
Mo's Algorithm
Mo.hMo.pyView -
Data Structures · range update, range query
Persistent Segment Tree
PersistentSegmentTree.hPersistentSegmentTree.pyView -
Data Structures · range queries
Segment Tree
SegmentTree.hSegmentTree.pyView -
Data Structures · range update, range query
Sparse Segment Tree
SparseSegmentTree.hSparseSegmentTree.pyView -
Data Structures · range queries
Square Root Decomposition
SRD.hSRD.pyView -
Dynamic Programming · digit DP
Digit DP
DigitDP.pyView -
Graphs · bfs
Breadth-First Search
BFS.pyView -
Graphs · union-find
DSU with Rollback
DSURollback.hDSURollback.pyView -
Graphs · dfs
Depth-First Search
DFS.pyView -
Graphs · shortest paths
Dijkstra's Algorithm
Dijkstra.pyView -
Graphs · union-find
Disjoint Set Union
DSU.hDSU.pyView -
Graphs · topological order
Topological Sort
TopoSort.pyView -
Trees · Euler tour
Euler Tour
EulerTour.hEulerTour.pyView -
Strings · trie
File System Trie
FileSystem.pyView -
Strings · hashing
Rolling Hash
rollinghash.hRollingHash.pyView -
Strings · trie
Trie
Trie.pyView -
Math · modular arithmetic
Factorials and Binomials mod p
ModFact.hModFact.pyView -
Math · modular arithmetic
Modular Inverse
ModInv.hModInv.pyView -
Databases · cache eviction
2Q Cache
lru-2q.hView -
Databases · storage structures
Bloom Filter
bloomfilter.hBloomFilter.pyView -
Databases · storage structures
Count-Min Sketch
countminsketch.hCountMinSketch.pyView -
Databases · storage structures
Cuckoo Filter
cuckoofilter.hCuckooFilter.pyView -
Databases · cache eviction
Eviction Cache Interface
eviction_cache.hView -
Databases · cache eviction
FIFO Cache
fifo.hView -
Databases · storage structures
Hash Function Factory
hash.hhash.pyView -
Databases · cache eviction
LFU Cache
lfu.hView -
Databases · cache eviction
LRU Cache
lru.hView -
Databases · storage structures
Quadtree
QuadTree.pyView -
Databases · storage structures
Skip List
skiplist.hSkiplist.pyView -
Utilities
Coordinate Compression
CoordinateCompression.hCoordinateCompression.pyView
Nothing matches. Try another word.