Problems > Polygon Diagonals > Editorial

Polygon Diagonals — Solution & Editorial

Back to the Problem

Each vertex connects to N−3 others by diagonals; halve to avoid double counting.

Complexity: O(1)

Watch out: N(N−3) overflows 32 bits well before N = 109.