Skip to content

Commit ab21d3b

Browse files
committed
Runtime: 2544 ms (Top 32.35%) | Memory: 73.6 MB (Top 48.94%)
1 parent a8c1d34 commit ab21d3b

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
1+
# Runtime: 2544 ms (Top 32.35%) | Memory: 73.6 MB (Top 48.94%)
12
class Solution:
2-
def maximumBeauty(self, items: List[List[int]], queries: List[int]) -> List[int]:
3+
def maximumBeauty(self, items: List[List[int]], queries: List[int]) -> List[int]:
34

4-
items.sort()
5-
dic = dict()
6-
res = []
7-
gmax = 0
8-
for p,b in items:
9-
gmax = max(b,gmax)
10-
dic[p] = gmax
5+
items.sort()
6+
dic = dict()
7+
res = []
8+
gmax = 0
9+
for p,b in items:
10+
gmax = max(b,gmax)
11+
dic[p] = gmax
1112

12-
keys = sorted(dic.keys())
13-
for q in queries:
14-
ind = bisect.bisect_left(keys,q)
15-
if ind<len(keys) and keys[ind]==q:
16-
res.append(dic[q])
17-
elif ind==0:
18-
res.append(0)
19-
else:
20-
res.append(dic[keys[ind-1]])
13+
keys = sorted(dic.keys())
14+
for q in queries:
15+
ind = bisect.bisect_left(keys,q)
16+
if ind<len(keys) and keys[ind]==q:
17+
res.append(dic[q])
18+
elif ind==0:
19+
res.append(0)
20+
else:
21+
res.append(dic[keys[ind-1]])
2122

22-
return res
23+
return res

0 commit comments

Comments
 (0)