Min Li's Note
KVM,QEMU, X86 virtualization
Pages
Home
Collection
About
Monday, December 22, 2014
Majority Element
Problem
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.
Idea
hash map 解决这个问题. 别忘记考虑只有1个元素的情况
Solution
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment