Concepts4
⚙️AlgorithmIntermediate
Modular Arithmetic Pitfalls
Modular arithmetic is about working with remainders, but programming languages often return negative remainders, so always normalize with (a % MOD + MOD) % MOD.
#modular arithmetic#modular inverse#fermats little theorem+12
⚙️AlgorithmIntermediate
Overflow Prevention Techniques
Integer overflow happens when a computed value exceeds the range of its type; in C++ this silently wraps for unsigned and is undefined for signed, so prevention is crucial.
#overflow prevention#long long#__int128+11
⚙️AlgorithmAdvanced
NTT (Number Theoretic Transform)
The Number Theoretic Transform (NTT) is an FFT-like algorithm that performs discrete convolutions exactly using modular arithmetic instead of floating-point numbers.
#ntt#number theoretic transform#polynomial multiplication+11
⚙️AlgorithmIntermediate
String Hashing (Polynomial Hash)
Polynomial string hashing encodes a string as a base-p number modulo a large prime, letting us compare substrings in O(1) after O(n) preprocessing.
#string hashing#polynomial hash#rolling hash+12