python中的bisect
python中的二分查找算法bisect
docs.python.org
在解决leetcode中的第0300题时看到的一个用法
class Solution(object):
def lengthOfLIS(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
tail = []
for num in nums:
idx = bisect.bisect_left(tail, num)
原创
2021-02-25 00:00:02 ·
145 阅读 ·
0 评论