BETA

Difficulty Level:

Basic

Total Submissions: 1972 Accuracy:

26.88%

Smallest number repeating K times
       

Given an array of size n, the goal is to find out the smallest number that is repeated exactly ‘k’ times.

Input:
First line consists of T test cases. First line of every test cases consists of 2 integers N and K. Second line of consists of every test case consists of array elements

Output:
Single line output, print the smallest number to be reapeted k times, else print -1.

Constraints:
1<=T<=100
1<=N<=1000

Example:
Input:

2
5 2
1 2 2 1 1
5 2
1 1 1 2 3
Output:
2
-1

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Saksham Raj Seth

Set Default Code

					   
It is recommended to 'Compile & Test' your code before clicking 'Submit'!

Compilation/Execution Result:

Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.