Mark As Completed Discussion

A lot of folks get tripped up by the majority part of this problem. The majority element is not the number with the most occurrences, but rather, it's the number value with >= 50% of "occurrences".

Step Two

The brute force solution would be manually iterate through and count the appearances of each number in a nested for-loop, like such: given an array [4, 2, 4]:

  1. iterate through for 4s, find 2 counts of 4
  2. iterate through for 2s, find 1 count of 2
  3. Realize that 2 > 3/2 (over half), so return 4