This question is not so hard. We know that only the majority no. has n/2 times. So after sorting the middle value in this vector is the result.

```
class Solution {
```

public:

int majorityElement(vector<int> &num) {

sort(num.begin(),num.end());

return num[num.size()/2];

}

};