First Element To Occur K Times

easy
1. Given an array of N integers. 2. The task is to find the first element that occurs K number of times. 3. If no element occurs K times the print -1. 4. Return your answer as integer. 5. Input and output is handled for you 6. It is a functional problem ,please do not modify main()

Input Format

first line contains N and K. second line contains n integers of array. Input is handled for you.

Output Format

Return an integer first element that occurs K times Output is handled for you.

Constraints

1 <= N, K <= 10^5
 1<= arr[i] <= 10^6

Notice

Try First, Check Solution later

1. You should first read the question and watch the question video.
2. Think of a solution approach, then try and submit the question on editor tab.
3. We strongly advise you to watch the solution video for prescribed approach.

Example

Input
7 2
1 7 4 3 4 8 7
Output
7
Previous
First Come First Serve
Next
First Repeating Element

Related Questions