Please enter your email address or userHandle.
There are N people in a room. If two persons shake hands exactly once, find the maximum number of handshakes possible.
Input: N = 2
Explaination: There are two people and they
can shake hands maximum one time.
Input: N = 3
Explaination: Let the people be person 1, 2 and 3.
So the possible handshakes are (1, 2), (2, 3) and
You do not need to read input or print anything. Your task is to complete the function handShakes() which takes N as input parameter and returns the maximum number of handshakes possible.
Expected Time Complexity: O(1)
Expected Auxiliary Space: O(1)
2 ≤ N ≤ 109
We strongly recommend solving this problem on your own before viewing its editorial. Do you still
want to view the editorial?
Login to access your submissions.