Walmart

Difficulty: EASYCategory: InterviewExperienceFrequency: 1Asked On 2020-11-02Added By Anonymous
Source: Link

you are given an integer n and two arrays each of which is a permutation of numbers from 1 to n. your task is to determine the number of unordered triplet (a,b,c) such that relative ordering of(a,b,c) is the same in both the arrays


Constraints

1≤T≤1001 \le T \le 100

1≤n≤1000001 \le n \le 100000


Sample Input1

3

1 2 3

1 2 3


Sample Output

1


Anyone plz give solution.

Comments