难度:medium

Given an integer array of size n, find all elements that appear more than ⌊ n/3 ⌋ times. The algorithm should run in linear time and in O(1) space.

思路:找到给定的array里面,出现次数超过总长度 1/3 的element。用hashtable解决,有点不明白为什么是medium难度。


leetcode 229[medium]--- Majority Element II




相关文章: