**Problem Description**

Given an integer array **A** and two integers **B** and **C**.

You need to find the number of subarrays in which the number of occurrences of **B** is equal to number of occurrences of **C**.

**NOTE:** Don't count empty subarrays.

1 <= |A| <= 10^{4}

1 <= A[i], B, C <= 10^{8}

B != C

First argument is an integer array **A**.

Second argument is an integer **B**.

Third argument is an integer **C**.

Return an integer denoting the number of subarrays in which the number of occurrences of **B** is equal to number of occurrences of **C**.

Input 1:

A = [1, 2, 1] B = 1 C = 2

Input 2:

A = {1, 2, 1} B = 4 C = 6

Output 1:

2

Output 2:

6

Explanation 1:

The possible sub-arrays have same equal number of occurrences of B and C are: 1) {1, 2}, B and C have same occurrence(1). 2) {2, 1}, B and C have same occurrence(1).

Explanation 2:

The possible sub-arrays have same equal number of occurrences of B and C are: 1) {1}, B and C have same occurrence(0). 2) {2}, B and C have same occurrence(0). 3) {1}, B and C have same occurrence(0). 4) {1, 2}, B and C have same occurrence(0). 5) {2, 1}, B and C have same occurrence(0). 6) {1, 2, 1}, B and C have same occurrence(0).

NOTE:You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.

- Hint 1
- Solution Approach
- Complete Solution

Loading...