How is majority determined ?


  • 1
    C

    if I have [1,1,1,2,2,2], why is 1 the majority number and not 2?


  • 0

    In your example, there is no majority element.


  • 0
    T

    The problem says that all inputs will have majority element, but there's still an expected result for the above array. It's misleading. We have to return something when there's no majority element found, otherwise the code won't compile. (e.g. Java/C/C++: missing return in non-void function)


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.