| 9 | int selectCandidate(vector<int>& a,int n); |
| 10 | int majorityElement(vector<int>& a,int n); |
| 11 | int 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 | } |
| 22 | int selectCandidate(vector<int>& a,int n){ |
| 23 | int index(0),frequency(1); |
| 24 | for(int i=1;i<n;i++){ |
nothing calls this directly
no test coverage detected