A custom test case which the expected answers got wrong

  • 0

    just tried to run custom test case: [1,2,3,1,1,4,4,1]
    which the correct result should return 1
    but the 'expected answers' on leetcode OJ is 4....interesting

  • 3

    It appears to me that you have 4 1's and a total of 8 numbers. 8/2 = 4 and a majority element is defined as greater than the floor of n/2 not greater than or equal to the floor of n/2. Your test case doesn't have a correct answer and the prompt doesn't allow for this situation, so you shouldn't be testing for this situation.

  • 0

    Got you, thanks for clarify my confusions.

Log in to reply

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