Associated Course(s):
Fork CPP

Given a vector of **N** positive integers and an integer **X**. The task is to find the **frequency **of X in vector.

Hint: You may use upper_bound and lower_bound.

**Input Format:**

First line of input contains number of testcases **T**. For each testcase there will be three lines. First line of which contains N, size of vector. Second line contains N positive integers seperated by space, and third line contains **X**, whose frequency is required.

**Output Format:**

For each testcase, print the frequency of X.

**User Task:**

Your task is to complete the function **findFrequency**() which should count the frequency of X and return it.

**Constraints:**

1 <= T <= 100

1 <= N <= 10^{6}

1 <= V[i] <= 10^{16}

**Example:
Input:**

1

5

1 1 1 1 1

1

5

**Explanation:
Testcase 1:** Frequency of 1 is 5.

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.

hardikJain5 | 258 |

CodeBuddy | 250 |

bhatabhi554 | 232 |

Akkki111 | 197 |

clone | 174 |

KshatriyaYash | 1932 |

nikhil_sojan | 1374 |

lonecoder | 1236 |

SumitSingh27 | 1127 |

mazumderrohit8 | 1124 |

blackshadows | 5327 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4591 |

Quandray | 4444 |

Login to report an issue on this page.