Tag: boyer moore voting algorithm

  • Find the element which appears more than half the array size

    Given an array, find the majority element which appears more than half the size of the array. Constraints: For example, in the below array: [7,6,8,7,7,7] The output is 7 since it appears 4 times which is more than half the size of the array (3) Solution: Finding a solution with O(n) extra space is easier.…