Problem:-
Given a List of N number a1,a2,a3........an, You have to find smallest number from the List that is repeated in the List exactly K number of times.
Input Format
First Line of Input Contain Single Value N, Size of List
Second Line of Input Contain N Space Separated Integers
Third Line of Input Contain Single Value K
Output Format
Smallest Integer Value That is Repeated Exactly K Number of Time
Constraints
- 0 < N < 100001
- 0 <= K < 100001
- 0 <= ai < 100001
NOTE
There Will Be Atleast One Variable Which Is Repeated K Times
Time Limit: 1
Memory Limit: 256
Source Limit:
Code:-
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,k,ele,a[100000]={0};
cin>>n;
for(int i=0;i<n;i++)
{
cin>>ele;
a[ele]++;
}
cin>>k;
for(int i=0;i<=100000;i++)
{
if(a[i]==k)
{
cout<<i<<endl;
break;
}
}
return 0;
}
0 Comments