K frequent(hashing)

Given an array A of N integers and a number K. The task is to print the numbers with K frequency.

Input:
First line of input contians number of testcases T. For each testcase, there will be two lines, first of which contains N and K, and next line contains N space seperated integers.

Output:
For each testcase, output the array elements in sorted order which are occurring K times in the array if present, else print -1.

Constraints:
1 <= T <= 100
1 <= N <= 106
1 <= A[i] <= 106
1 <= K <= 106

Example:
Input:
1
5 2
1 2 3 4 1

Output:
1

Explanation:
Testcase 1: In the given array, 1 is present 2 times.

where i am going wrong in my code :-

https://ide.geeksforgeeks.org/CaZt7yOczc

mention the question link pls

https://practice.geeksforgeeks.org/contest-problem/kth-frequency/0

int hash[1000000] is not right.
You should write hash[1000001] because array is upto 10^6.
you should use unordered_map STL here because if A[i]<=10^9 , you would not able to make hash[10^9] cozz maximum array size you can make is 10^7