This algorithm finds the majority element only if there is one.

For more info click below.

https://en.wikipedia.org/wiki/Boyer–Moore_majority_vote_algorithm

```
int majorityElement(int * nums, int numsSize)
{
// Boyer–Moore majority vote algorithm
int i, m, cm;
cm = 1; m = nums[0];
for (i = 1; i < numsSize; ++i)
{
if (!cm)
{
m = nums[i];
cm = 1;
}
else if (m == nums[i])
++cm;
else
--cm;
}
return m;
}
```