Given an array A of N elements. Find the majority element in the array. A majority element in an array A of size N is an element that appears more than N/2 times in the array.
- Time : O(n)
- Space : O(1)
1 | int majorityElement(int a[], int size) { |
Given an array A of N elements. Find the majority element in the array. A majority element in an array A of size N is an element that appears more than N/2 times in the array.
1 | int majorityElement(int a[], int size) { |