1996. The Number of Weak Characters in the Game

Updated: 2024-03-12
1 min read
[]

On This Page

LeetCode problem 1996

class Solution:
    def numberOfWeakCharacters(self, properties: List[List[int]]) -> int:
        properties.sort(key=lambda x: (-x[0], x[1]))
        res = mx = 0
        for _, x in properties:
            res += x < mx
            mx = max(mx, x)
        return res