Count of triplets of numbers 1 to N such that middle element is always largest | Java 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
import java . io . * ; import java . util . * ; class GFG { static int findArrangement ( int N ) { if ( N < 3 ) return 0 ; return ( ( N ) * ( N - 1 ) * ( N - 2 ) ) / 3 ; } public static void main ( String [ ] args ) { int N = 10 ; System . out . println ( findArrangement ( N ) ) ; } }