InferenceAI

Enter at least two characters to search.

Start free

Majority Vote

easyAgents12 min10 XP

Return the most frequent answer. Break ties by whichever answer appeared first.

Examples

EXAMPLE WALKTHROUGHmajority

A guided view of the published example, not a trace of your code.

INPUT[["yes","no","yes"]]
TASKmajority_vote()
EXPECTED OUTPUT"yes"

Start with the input values shown in this example.

Example 1 of 2

Input: answers = ["yes","no","yes"]

Output: "yes"

Explanation: majority

Input: answers = ["b","a"]

Output: "b"

Explanation: tie

Hint 1

Track counts and first positions.

Topics

PythonAgents