I need make this code better..


  • 0
    W

    Come on,guys,how to make this code better.I think it's a bit awesome

    class Solution {
    public:
    int majorityElement(vector<int>& nums) {
        int len = nums.size();
        if(len == 1) return nums[0];
        sort(nums.begin(),nums.end());
        return nums[len/2];
    }
    

    };


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.