Given the fact that any two persons shake hand exactly once, Find the total count of handshakes that happened in that meeting.
Example:
Input: n = 2
Output: 1
Approach
C++
#include <bits/stdc++.h>using namespace std;int noHandshakes(int n){int res = n * (n - 1) / 2;return res;}int main(){int n = 2;cout << noHandshakes(n);return 0;}
No comments:
Post a Comment