leetcode180专题

Leetcode180: Majority Element II

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. 因为不超过n/3个数的数最多只有2个,可以定义两个变量,利用类似Majority Element中