A settings page asked users to vote for their favorite theme. The votes are in votes, and one theme is guaranteed to have more than half of them.
Write pollWinner(votes) that returns that theme. Try to use only O(1) extra memory.
Input: votes = ["dark","light","dark","dark","system"] Output: "dark"
dark has 3 of the 5 votes.
Input: votes = ["a"] Output: "a"
A single vote is a majority.
1 <= votes.length <= 10^5votes.length / 2 times.Run tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #67 Poll Winner With a Majority. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.