Company: Arista
Difficulty: hard
Count Increasing Triplets Under a Threshold You are given an integer array arr of length n and an integer t representing a threshold. Count the number of triplets of indices (i, j, k) such that: 0 <= i < j < k < n arr[i] < arr[j] < arr[k] arr[i] + arr[j] + arr[k] <= t Return the total number of such triplets. Note that the values must increase strictly , so a triplet in which two of the three values are equal never counts. Function Description Complete the function countTriplets in the editor, with the following parameters: int arr[n] : the array long t : the threshold Return long : the number of index triplets (i, j, k) that satisfy all three conditions. Constraints 3 <= n <= 4000 -10^9 <= arr[i] <= 10^9 -3 10^9 <= t <= 3 10^9 The answer can exceed the range of a 32-bit integer. Input Format for Custom Testing Input from stdin will be processed as follows and passed to the function. The first line contains an integer n , the length of arr . The s