Ninja loves cherry biscuits. He brings a packet of biscuits from a shop which contains ‘N’ biscuits. The number of cherries present in each biscuit is given in an array ‘A’.
Ninja likes a biscuit only if the number of cherries in that biscuit is strictly greater than ‘K’.
Can you tell the number of biscuits Ninja likes?
Example :N = 3
K = 5
A = [ 1, 6, 7 ]
Biscuit 1 : Since there is only 1 cherry in this biscuit which is not greater than ‘K’, Ninja doesn’t like this biscuit.
Biscuit 2 : Since there are 6 cherries in this biscuit which is greater than ‘K’, Ninja likes this biscuit.
Biscuit 3 : Since there are 7 cherries in this biscuit which is greater than ‘K’, Ninja likes this biscuit.
Hence, Ninja likes 2 biscuits from this packet.
The first line contains an integer 'T' which denotes the number of test cases to be run. Then the test cases follow.
The first line of each test case contains integer ‘N’.
The second line of each test case contains integer ‘K’.
The second line contains ‘N’ space separated integers denoting the elements of array ‘A’.
Output format :
For each test case, print one integer denoting the number of biscuits Ninja likes.
Print the output of each test case in a new line.
Note :
You don’t need to print anything. It has already been taken care of. Just implement the given function.
1 <= T <= 10
1 <= N <= 10^4
0 <= K <= 10^9
0 <= A[i] <= 10^9
Time Limit: 1 sec
2
2
1
2 1
4
4
1 5 3 7
1
2
For test case 1 we have,
Biscuit 1 : Since there are 2 cherries in this biscuit which is greater than ‘K = 1’, Ninja likes this biscuit.
Biscuit 2 : Since there is 1 cherry in this biscuit which is not greater than ‘K = 1’, Ninja doesn’t like this biscuit.
Hence, Ninja likes 1 biscuit from this packet.
For test case 2 we have,
Biscuits with cherries 5 and 7 respectively have values greater than ‘K = 4’, hence Ninja likes these biscuits.
Hence, we output 2.
3
3
6
1 5 4
2
6
5 7
3
0
1 2 3
0
1
3
Simulate the Problem Statement.
Approach :
Algorithm :
O(N) , where ‘N’ is the length of the array ‘A’.
Since we are traversing the array once, the overall time complexity is O(N).
O(1)
Constant extra space is required. Hence, the overall Space Complexity is O(1).