Problems > Handshakes All Around > Editorial

Handshakes All Around — Solution & Editorial

Back to the Problem

Apply the closed form directly — derive it by pairing/telescoping if unfamiliar.

Complexity: O(1)

Watch out: The result overflows 32-bit — use 64-bit (or big) integers.