Polygon Diagonals — Solution & Editorial
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.
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.