
The first line contains a single integer ‘T’ representing the number of test cases.
The first line of each test case will contain a single integer ‘N’, which denotes the number of people in the row.
The second line of each test case will contain ‘N’ integers that denote each particular person’s height in the row.
For each test case, print the number of ways to select three people according to the condition given in the description.
Output for every test case will be printed in a separate line.
You don’t need to print anything; It has already been taken care of. Just implement the given function.
1 <= T <= 10
3 <= N <= 100
1 <= ARR[i] <= 10 ^ 5
Where 'ARR[i]' denotes the height of the i-th people in the row.
Time limit: 1 sec
The basic idea is to iterate through all possible triplet of people in the row using three loops.
The basic idea of this approach is to calculate the number of possible triplets of people, which follows the required condition by calculating the number of people with less height than the ‘i-th’ people on his left side and the number of people with greater height on his right side.
The basic idea of this approach is to pre-calculate the number of people with less height on the left side of each individual people and the number of people with the greater height on the right side of each people, this is done by using a segment tree first for the left side and then for the right side. Here, the elements of the array are not changing and so, we will use the offline approach.
Merge Two Sorted Arrays Without Extra Space
Merge Two Sorted Arrays Without Extra Space
Co-Prime
Distinct Queries on Tree
First Digit One
Special Digit Numbers