Skip to content
DeepForgeby svx
All problems
EasyNLPnlp-229

Majority Vote

Problem

Return the most frequent answer, breaking ties alphabetically.

Return an empty string for empty input.

Hint

Iterate sorted keys and keep the first strict maximum.

Test cases

case 1
in: [["a","b","a"]]
expected: "a"
case 2
in: [["a","b"]]
expected: "a"
case 3
in: [[]]
expected: ""
case 4
in: [["b","b","a"]]
expected: "b"
Starter codePython
def majority_vote(answers):
    # Your code here
    pass

4 test cases · run your code against them in the editor