import bisect
class Solution:
def longestObstacleCourseAtEachPosition(self, obstacles: List[int]) -> List[int]:
lis = []
result = []
for obstacle in obstacles:
idx = bisect.bisect_right(lis, obstacle)
if idx == len(lis):
lis.append(obstacle)
else:
lis[idx] = obstacle
print(idx, lis, obstacle)
result.append(idx+1)
return result
'CS > 알고리즘' 카테고리의 다른 글
[Leetcode] 1572. Matrix Diagonal Sum (0) | 2023.05.09 |
---|---|
[Leetcode] 1498. Number of Subsequences That Satisfy the Given Sum Condition (1) | 2023.05.06 |
[Leetcode] 1456. Maximum Number of Vowels in a Substring of Given Length (0) | 2023.05.06 |
[Leetcode] 649. Dota2 Senate (0) | 2023.05.05 |
[Leetcode] 986. Interval List Intersections (0) | 2023.05.05 |