Given an array and two integers say, **x **and **y**, find the number of sub-arrays in which the number of occurrences of **x** is equal to number of occurrences of **y**.

```
Input : arr[] = {1, 2, 1},
x = 1, y = 2
Output : 2
The possible sub-arrays have same equal number
of occurrences of x and y are:
1) {1, 2}, x and y have same occurrence(1).
2) {2, 1}, x and y have same occurrence(1).
```

**Input:**

The first line consists of an integer **T** i.e number of test cases. The first line of each test case consists of three integers **N**,**x** and **y**.The next line consists of **N** spaced integers.

**Output:**

Print the count of total number of sub-arrays satisfying specified condition.

**Constraints: **

1<=T<=100

1<=N,a[i],x,y<=100

**Example:
Input:**

2

3 1 2

1 2 1

3 4 6

1 2 1

**Output:**

2

6

Author: saksham0751

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.

jhasaurabh312 | 138 |

Aaaaarohiiii | 136 |

Harsha_kunchala | 128 |

tushki | 124 |

RajaRajput | 117 |

ARUN_PUNDIR | 617 |

manishgupta8497 | 607 |

Abhimanyu_kumar | 559 |

KhyatiSoneji | 501 |

Aman___Jain | 496 |

blackshadows | 5335 |

Ibrahim Nash | 5223 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4567 |

Login to report an issue on this page.