今際の国の呵呵君
Monday, September 24, 2018
[LeetCode]Online Election
这道题的思路其实很简单,知道所有的投票和对应的时间点,我们可以把每个时间点当前对应的胜者算出来。之后对于给定的time,我们binary search即可。时间复杂度O(N + M * log N),N为输入数组的长度吗,M为query的次数,代码如下:
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment