Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from sortedcontainers import SortedList
- class Solution:
- def numberOfWeakCharacters(self, properties: List[List[int]]) -> int:
- properties.sort(key=lambda p: (p[0], -p[1]))
- defenses = SortedList(p[1] for p in properties)
- ans = 0
- for p in properties:
- defenses.remove(p[1])
- if not defenses:
- break
- if p[1] < defenses[-1]:
- ans += 1
- return ans
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement