I have an array which is taking in values. at some point during this process, a “find(n, x)” command is given as input. The find command is supposed to find the number of occurrences of n between index x and current index. x is definitely less than the current index. For example, the input goes like:

1

2

3

2

1

4

1

find(1, 3)

2

2

4

1

find(2, 3)

%------------------%

output:

2 (because there are 2 ones between index 3 and the index when find(1, 3) is called).

3 (because there are 2 twos between index 3 and the index when find(2, 3) is called).

%------------------%

How can I implement this? please explain.