We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
原题链接:https://leetcode-cn.com/problems/majority-element/
解题思路:
/** * @param {number[]} nums * @return {number} */ var majorityElement = function (nums) { // 将数组排序 nums.sort((a, b) => a - b); // 查找中间项的索引 const middleIndex = Math.floor(nums.length / 2); // 中间项的值即为多数元素 return nums[middleIndex]; };
The text was updated successfully, but these errors were encountered:
No branches or pull requests
原题链接:https://leetcode-cn.com/problems/majority-element/
解题思路:
The text was updated successfully, but these errors were encountered: