GoLang Solution For LeetCode Problem: Online Election
Solving Online Election in go. Please try yourself first to solve the problem and submit your implementation to LeetCode before looking into solution.
Problem Description
Example 1:
Input: ["TopVotedCandidate","q","q","q","q","q","q"], [[[0,1,1,0,0,1,0],[0,5,10,15,20,25,30]],[3],[12],[25],[15],[24],[8]]
Output: [null,0,1,1,0,0,1]
Explanation:
At time 3, the votes are [0], and 0 is leading.
At time 12, the votes are [0,1,1], and 1 is leading.
At time 25, the votes are [0,1,1,0,0,1], and 1 is leading (as ties go to the most recent vote.)
This continues for 3 more queries at time 15, 24, and 8.
Note:
1 <= persons.length = times.length <= 5000
0 <= persons[i] <= persons.length
1 <= persons.length = times.length <= 5000
0 <= persons[i] <= persons.length
See the full details of the problem Online Election at LeetCode
Originally posted at: @github.com/halfrost/LeetCode-Go
Comments
Leave a comment
You are not LoggedIn but you can comment as an anonymous user which requires manual approval. For better experience please Login.