Total Accepted: 92197
Total Submissions: 232301
Difficulty: Easy
Given an array of size _n_, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋
times.
You may assume that the array is non-empty and the majority element always exist in the array.
还是hash,hash中过半即答案
C++:
1 | class Solution { |