MCPcopy Create free account
hub / github.com/Tiwarishashwat/InterviewCodes / isMajority

Method isMajority

MajorityElementBoyerMooreVoting.java:3–14  ·  view source on GitHub ↗
(int a[], int size, int candidate)

Source from the content-addressed store, hash-verified

1class Solution
2{
3 static boolean isMajority(int a[], int size, int candidate)
4 {
5 int counter=0;
6 for(int i=0;i<size;i++)
7 {
8 if(a[i]==candidate)
9 {
10 counter++;
11 }
12 }
13 return (counter>size/2);
14 }
15 static int majorityElement(int a[], int size)
16 {
17 // your code here

Callers 1

majorityElementMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected