Given Array N Distinct Integers D D 0 D 1 D N 1 Integer Threshold T Many B C Index Triple Q43816057
Given an array of n distinct integers, d =[d[0], d[1],..,d[n-1]], and an integer threshold ,t , how many (a,b,c) indextriplets exist that satisfy both of the following conditions?
d[a] < d[b] < d[c]
d[a] + d[b] + d[c] ≤ t
Function Description
Complete the function triplets in the editor below. The functionmust return a long integer denoting the number of (a,b,c) tripletssatisfying the given conditions:
t: an integer treshold
d[d[0],….d[n-1]] : an array of integers
Constraints
1 ≤ n ≤ 104
0 ≤ d[i] < 109
0 < t < 3 x109

in C++ plz
#include <bits/stdc++.h>… / Complete the triplets function below. long triplets (long t, vector int> d) { int main() ofstream fout(getenv(“OUTPUT_PATH”)); string t_temp; getline (cin, t_temp); long t = stol(ltrim(rtrim(t_temp))); string d_count_temp; getline (cin, d_count_temp); int d_count = stoi(ltrim(rtrim(d_count_temp))); vector int> d(d_count); for (int i = 0; i < d_count; i++) { string d_item_temp; getline (cin, d_item_temp); int d_item = stoi(ltrim(rtrim(d_item_temp))); d[i] = d_item; long res = triplets(t, d); fout << res << “n”; fout.close(); return 0; string ltrim(const string &str) { string s(str); S.erase Show transcribed image text #include … / Complete the triplets function below. long triplets (long t, vector int> d) { int main() ofstream fout(getenv(“OUTPUT_PATH”)); string t_temp; getline (cin, t_temp); long t = stol(ltrim(rtrim(t_temp))); string d_count_temp; getline (cin, d_count_temp); int d_count = stoi(ltrim(rtrim(d_count_temp))); vector int> d(d_count); for (int i = 0; i
Expert Answer
Answer to Given an array of n distinct integers, d =[d[0], d[1],.., d[n-1]], and an integer threshold ,t , how many (a,b,c) index …
OR