Skip to content

Latest commit

 

History

History
33 lines (26 loc) · 691 Bytes

2102.md

File metadata and controls

33 lines (26 loc) · 691 Bytes

2101. Detonate the Maximum Bombs

Solution 1 (time O(log(n)), space O(n))

class SORTracker(object):

    def __init__(self):
        self.data = []
        self.query_num = 0

    def add(self, name, score):
        """
        :type name: str
        :type score: int
        :rtype: None
        """
        bisect.insort(self.data, (-score, name))

    def get(self):
        """
        :rtype: str
        """
        ans = self.data[self.query_num][1]
        self.query_num += 1
        return ans


# Your SORTracker object will be instantiated and called as such:
# obj = SORTracker()
# obj.add(name,score)
# param_2 = obj.get()