Thursday, December 31, 2015

229. 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.
Hint:
  1. How many majority elements could it possibly have?
  2. Do you have a better hint?
Java Code:

No comments:

Post a Comment