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.
Credits: Special thanks to @ts for adding this PRoblem and creating all test cases.
Subscribe to see which companies asked this question.
Show Tags Show Similar Problems
思路是vector減去兩個(gè)不同的數(shù)字后那個(gè)超過一半的數(shù)字還是不變的 ,通過不斷去除兩個(gè)不同的數(shù)來縮小范圍
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注