首页 > 其他 > 详细

leetcode-12双周赛-1244-力扣排行榜

时间:2019-11-05 12:46:38      阅读:103      评论:0      收藏:0      [点我收藏+]

题目描述:

技术分享图片

 

 

 技术分享图片

 

 

 

class Leaderboard:

    def __init__(self):
        self.map = collections.Counter()

    def addScore(self, playerId: int, score: int) -> None:
        self.map[playerId] += score

    def top(self, K: int) -> int:
        return sum(sorted(self.map.values(),reverse = True)[:K])

    def reset(self, playerId: int) -> None:
        self.map[playerId] = 0


# Your Leaderboard object will be instantiated and called as such:
# obj = Leaderboard()
# obj.addScore(playerId,score)
# param_2 = obj.top(K)
# obj.reset(playerId)

 

leetcode-12双周赛-1244-力扣排行榜

原文:https://www.cnblogs.com/oldby/p/11797529.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!