Loading...
You are given an array votes of ballots from an election among a fixed set of candidates, each named by an uppercase letter. Each ballot is a string ranking all candidates from most to least preferred, and every ballot ranks the same set of candidates.
The final order is decided positionally:
Return a string of all candidates in final order.
Input: votes = ["ABC", "ACB", "ABC", "ACB", "ACB"]
Output: "ACB"
Explanation: A is ranked first by all 5 voters. C beats B on second-place
votes, 3 to 2.
Input: votes = ["WXYZ", "XYZW"]
Output: "XWYZ"
Explanation: X and W tie on first-place votes; X wins on second-place votes.
Input: votes = ["ZMNAGUEDSJYLBOPHRQICWFXTVK"]
Output: "ZMNAGUEDSJYLBOPHRQICWFXTVK"
votes.length ≤1000votes[i].length ≤26Click "Run" to test with sample cases or "Submit" to run all tests.