class Solution:
def frequencySort(self, s: str) -> str:
res = collections.Counter(s)
return ''.join(c*res[c] for c in sorted(res, key = res.get)[::-1])
class Solution:
def findMinArrowShots(self, points: List[List[int]]) -> int:
points = sorted(points,key = lambda x:x[1])
l = len(points)-1
i = 0 #存储当前遍历索引
res = 0 #存储最后箭的个数
while i <= l:
end = points[i][1]
res += 1
i += 1
while i<=l and points[i][0]<=end:
i += 1
return res
class Solution:
def fourSumCount(self, A: List[int], B: List[int], C: List[int], D: List[int]) -> int:
res = 0
count = {}
for a in A:
for b in B:
count[a+b] = count.get(a+b,0)+1 #去A和B的和存入字典
for c in C:
for d in D:
res += count.get(-c-d,0) #判断C+D的和的相反数是否在字典中
return res