You are given an array X of n elements, write a program to find majority element in an array. A majority element is an element that appears more than n/2 times, so there is at most one such element. Assume that array is non-empty and majority element always exists in the array. Note: This is an excellent problem to learn various approaches.
Subscribe to get well designed content on data structure and algorithms, machine learning, system design, object orientd programming and math.