Skip to content

Latest commit

 

History

History

challenge_3

#Majority Element

##Premise

  • 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.

for example, given array = [2,2,3,7,5,7,7,7,4,7,2,7,4,5,6,7,7,8,6,7,7,8,10,12,29,30,19,10,7,7,7,7,7,7,7,7,7] your program should return 7

Testing

Expected input:

2,2,3,7,5,7,7,7,4,7,2,7,4,5,6,7,7,8,6,7,7,8,10,12,29,30,19,10,7,7,7,7,7,7,7,7,7

Expected output:

7