Find Majority Element
Advanced
Find Majority Element
In this challenge, you will write a Python function to find the majority element in a list of numbers.
The majority element is the element that appears more than half the time in the list.
Your task is to implement the function find_majority_element(numbers). The function will receive a list of integers and will return the majority element.
Here's a clue: There will always be a majority element in the input list, so you don't need to worry about cases where there isn't one.
Examples
find_majority_element([3, 2, 3])
The function should return 3, since 3 appears twice while 2 appears once.
find_majority_element([2, 2, 1, 1, 1, 2, 2])
The function should return 2, as 2 appears 4 times which is more than half (3.5) of the list length.
Have fun with this challenge and see if you can come up with an efficient solution!
Inputs
Arg 1:
[3,2,3]Expected Output
3Actual Output