MCPcopy Create free account
hub / github.com/Vishruth-S/CompetitiveCode / main

Function main

LeetCode_problems/Majority Element/solution2.cpp:11–21  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9int selectCandidate(vector<int>& a,int n);
10int majorityElement(vector<int>& a,int n);
11int main(){
12 int t;
13 cin>>t;
14 while(t--){
15 int n;
16 cin>>n;
17 vector<int>a(n);
18 for(auto &i:a)cin>>i;
19 cout<<majorityElement(a,n)<<endl; // returns -1 if there's no such element with count greater than n/2;
20 }
21}
22int selectCandidate(vector<int>& a,int n){
23 int index(0),frequency(1);
24 for(int i=1;i<n;i++){

Callers

nothing calls this directly

Calls 1

majorityElementFunction · 0.85

Tested by

no test coverage detected