Question: DON'T USE HASH MAP , OR MAP YOU CAN USE ARRAYS An integer number is interesting if it appears at least k times in a
DON'T USE HASH MAP , OR MAP
YOU CAN USE ARRAYS
An integer number is interesting if it appears at least ktimes in a list. Given Ninteger numbers, and another integer k, your task is to find how many interesting numbers are there in the list. Input The input will start with an integer T (100 > T > 0), denoting the number of test cases to follow. Each test case starts with a line containing two integer numbers N (0 < N < 100) and k(0 < k< N). Then the next line contains Ninteger (32-bit signed) numbers separated by spaces.
Output For each test case, there should be one line of output, containing the count of interesting numbers.
Sample
| Input | Output |
| 2 7 2 10 3 20 20 3 8 3 5 4 10 3 3 2 98 | 2 0 |
Explanation of the inputs and outputs:
The first number (2) denotes the total test cases.
The first test case has N = 7 and k= 2
There are 7 numbers in the list (10, 3 ) of which 10 appears once, 3 appears 3 times, 20 appears twice, and 8 appears once. Since k = 2, then 10 and 8 are not interesting (they appear less than 2 times). Therefore, 3 and 20 are interesting, meaning, there are 2 interesting numbers. So, the output is 2.
In the second test case, k = 4, and since there is no number appearing at least 4 times, there is no interesting number. Therefore, the output is 0.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
