threeal / leetspace

A dedicated workspace and archive for my LeetCode submissions
https://leetcode.com/threeal
MIT License
1 stars 1 forks source link

Solve Problem 911. Online Election #1384

Open threeal opened 1 month ago

threeal commented 1 month ago

This issue suggests solving the problem 911. Online Election. To achieve this, one can store the top vote candidate in an array for each given time. Since the given votes are already sorted by time, the top vote candidate for each time can be calculated by simply iterating through the given votes. To speed up queries, a binary search can be utilized to find the top vote at the given time.