Smallest number repeating K times
Submissions: 2777   Accuracy:

31.05%

  Difficulty: Basic   Marks: 1

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 repeated k times, else print -1.

Constraints:
1<=T<=100
1<=N<=10000
1<=K<=10

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
Author: saksham seth


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.



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

to report an issue on this page.