Count pair sum
Submissions: 2098   Accuracy:

48.3%

  Difficulty: Basic   Marks: 1

Given two sorted arrays of size m and n of distinct elements. Given a value x. The problem is to count all pairs from both arrays whose sum is equal to x.
Note: The pair has an element from each array.

Input:
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case contains two integers m and n denoting the size of the two arrays. The next two lines contains the two arrays arr1 and arr2 respectively. The last line contains the value of sum x.

Output:
Print the count of all pairs from both arrays whose sum is equal to x.

Constraints:
1<=T<=100
1<=m,n<=10^5
1<=arr1[i],arr2[j]<=10^5
1<=k<=10^5

Example:
Input:

2
4 4
1 3 5 7
2 3 5 8
10
7 7
1 2 3 4 5 7 11
2 3 4 5 6 8 12
9

Ouput:
2
5

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Ayush Govil
Author: Ayush Govil 1


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.