
算法思维
BobChill
这个作者很懒,什么都没留下…
展开
-
mergesort与逆序对个数
mergesort代码如下:def merge_lists(left, right): res = [] lc = rc = 0 while lc < len(left) and rc < len(right): if left[lc] <= right[rc]: res.append(left[lc]) lc += 1 else: res.append(r原创 2020-11-23 21:21:25 · 397 阅读 · 0 评论 -
快速排序-python极简版
def qsort(seq): if seq == [] or seq is None: return else: pivot = seq[0] lesser = qsort([x for x in seq[1:] if x<pivot]) greater = qsort([x for x in seq[1:] if x>=pivot]) return lesser + [pivot] + grea.原创 2020-11-22 01:12:35 · 161 阅读 · 0 评论 -
sliding window 编程范式python
滑动窗口(Sliding Window)问题经常使用快慢指针(slow, fast pointer)[0, slow) 的区域为滑动窗口已经探索过的区域 [slow, fast]的区域为滑动窗口正在探索的区域 (fast, end of array)为待探索的区域 Sliding Window的问题主要分为:fixed size sliding window dynamic siz...原创 2018-12-14 14:01:02 · 1710 阅读 · 0 评论 -
Backtracking 编程范式python
choose-> explore-> unchoose paradigm is the key! below is the general pseudo code 来看看例子一:Given a collection of distinct integers, return all possible permutations.Input: [1,2,3]Output...原创 2018-12-19 20:05:58 · 666 阅读 · 0 评论