两行代码搞定。。。。
class Solution { public: int MoreThanHalfNum_Solution(vector<int> numbers) { sort(numbers.begin(),numbers.end()); return numbers[numbers.size()/2]; } };
两行代码搞定。。。。
class Solution { public: int MoreThanHalfNum_Solution(vector<int> numbers) { sort(numbers.begin(),numbers.end()); return numbers[numbers.size()/2]; } };