My code works in XCode, but when I submitted it to Leetcode, it gave me a RunTimeError on big input.

Here is my code:

```
class Solution {
public:
int majorityElement(vector<int> &num) {
int max = findMax(num);
vector<int> count(max,0);
for (int i = 0; i < num.size(); i++){
count[num[i]-1] ++;
}
int majEleCount = num.size()/2;
for (int i = 0; i < max; i++){
if (count[i] >= majEleCount) return (i+1);
}
return 0;
}
int findMax(vector<int> &num){
int max = num[0];
for (int i =0; i < num.size(); i++){
if (num[i] > max) max = num[i];
}
return max;
}
};
```