Leaderboard
Showing:
Handle Score
@Ibrahim Nash 5725
@blackshadows 5685
@akhayrutdinov 5111
@mb1973 4989
@Quandray 4908
@saiujwal13083 4156
@sanjay05 3762
@marius_valentin_dragoi 3511
@sushant_a 3453
@KshamaGupta 3318
@the_coder95 3302
Complete Leaderboard
First Come First Serve
Basic Accuracy: 50.38% Submissions: 4254 Points: 1

CodeMart is an online shopping platform and it is distributing gift vouchers to its esteemed users. The voucher can be redeemed by providing a fixed amount of shopping credits.Each credit is sent by a user one by one. Since there is a huge rush of people you are required to manage the users on the basis of first come first serve. The user which comes first and has k occurrences of credits is given the voucher first. You are given an array with the id's of the users in chronological order of the credits sent by them. You are required to print the id of the user which will be served first. If no such user meets the condition print "-1".    

Input:
The first line of input contains an integer T denoting the number of test cases. Each test case contains two integers n and k where n denoted the number of elements in the array a[]. Next line contains space separated n elements in the array a[].

Output:
Output a single integer which is the number of first k occurrences. Output "-1" if no such number exists.

Constraints:
1<=T<=10
1<=n<=1000
1<=a[i]<=100000
1<=k<=100

Example:
Input:

2
7 2
1 7 4 3 4 8 7
6 1
4 1 6 1 6 4
Output:
7
-1

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.

First Come First Serve

Output Window