← Divide & Conquer
Divide & Conquer Target: 15s
Binary exponentiation computes x^n in O(log n). Essential for modular arithmetic problems.
res = 1 while exp: if exp & 1: res *= base base *= base exp >>= 1
Type it from memory. Go.