Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Grouping values #24

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions Grouping values
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/ { Driver Code Starts
// Initial Template for C++

#include<bits/stdc++.h>
using namespace std;

// } Driver Code Ends


// User function Template for C++

class Solution{
public:
int isPossible(int N, int arr[], int K){
// code here
map<int,int> m;
for(int i=0;i<N;i++){
m[arr[i]]++;
}
int a =INT_MIN;
for(auto e:m){
a = max(a , e.second);
}
if((2*K)<a)return 0;
return 1;
}
};

// { Driver Code Starts.

int main(){
int t;
cin>>t;
while(t--){
int N, K;
cin>>N;
int arr[N];
for(int i = 0;i < N;i++)
cin>>arr[i];
cin>>K;

Solution ob;
cout<<ob.isPossible(N, arr, K)<<"\n";
}
return 0;
} // } Driver Code Ends