Advertisement
kosievdmerwe

1996

Sep 8th, 2022
987
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.51 KB | None | 0 0
  1. from sortedcontainers import SortedList
  2.  
  3. class Solution:
  4.     def numberOfWeakCharacters(self, properties: List[List[int]]) -> int:
  5.         properties.sort(key=lambda p: (p[0], -p[1]))
  6.        
  7.         defenses = SortedList(p[1] for p in properties)
  8.        
  9.         ans = 0
  10.         for p in properties:
  11.             defenses.remove(p[1])
  12.             if not defenses:
  13.                 break
  14.                
  15.             if p[1] < defenses[-1]:
  16.                 ans += 1
  17.                
  18.         return ans
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement