Count number of elements between two given elements in array
Submissions: 2318   Accuracy:

33.65%

  Difficulty: Basic   Marks: 1

Given an unsorted array and two elements num1 and num2. The task is to count the number of elements occurs between the given elements (excluding num1 and num2). If there are multiple occurrences of num1 and num2, we need to consider leftmost occurrence of num1 and rightmost occurrence of num2.

Input:
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case consists of three lines. First line of each test case contains an Integer N denoting size of array, second line contains N space separated array elements and third line contains two elements num1 and num2.

Output:
For each test case, print the count in new line.

Constraints:
1<=T<=200
2<=N<=105
1<=A[i],num1,num2<=105

Example:
Input:

2
5
4 2 1 10 6

4 6
4
3 2 1 4

2 4

Output:
3
1

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

Author: arun03


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.