You are given an integer n and two arrays each of which is a permutation of numbers from 1 to n.
Task
Your task is to determine the number of unordered triplets (a,b,c) such that the relative ordering of (a,b,c) is the same in both the arrays.
Example
Assumptions
Approach
There exist two unordered triplets such that the relative ordering of triplet is same in both the permutation arrays:
Function description
Complete the countTriplet function provided in the editor. The function takes the following 3 parameters and returns the number of ordered triplets.
Input format
Note: This is the input format that you must use to provide custom input (available above the Compile and Test button).
Output format
For each test case, print the number of ordered triplets in a new line
Constraints
1≤T≤100
1≤n≤100000
Code snippets (also called starter code/boilerplate code)
This question has code snippets for C, CPP, Java, and Python.
Its possible to select only one triplet in both the arrays, i.e., (1,2,3) and the relative ordering of this triplet is same in both the arrays.