First element occurring k times in an array
Execution time limit is 1 second
Runtime memory usage limit is 128 megabytes
Given an array of n integers. Find the first element that occurs k number of times. If no element occurs k times, print -1.
Input
The first line contains numbers n and k (n, k ≤ 10^5
). Second line contains n integers, each no more than 10^9
by absolute value.
Output
Print the first element that occurs k times. If no element occurs k times, print -1.
Examples
Input #1
Answer #1
Input #2
Answer #2
Submissions 738
Acceptance rate 50%