Count of triplets of numbers 1 to N such that middle element is always largest | C ++ program to implement the above approach ; Function to find Number of triplets for given Number N such that middle element is always greater than left and right side element . ; check if arrangement is possible or Not ; else return total ways ; Driver code .
#include <bits/stdc++.h> NEW_LINE using namespace std ; int findArrangement ( int N ) { if ( N < 3 ) return 0 ; return ( ( N ) * ( N - 1 ) * ( N - 2 ) ) / 3 ; } int main ( ) { int N = 10 ; cout << findArrangement ( N ) ; return 0 ; }