摘要: 通过排序后,依次遍历前后两值求差即可,所以实质上的核心问题是排序;通过经典的比较排序算法复杂度在O(nlogn),而如果数据波动不大,则可通过桶排序将复杂度降到O(n);array = (5, 2, 4, 9, 0, 6)# quick sort# O(nlogn)def split(list, start, end): middle = list[end] index = start -1 for i in range(start, end+1): if list[i] max_e: max_e = i if i = 2:... 阅读全文
posted @ 2013-09-05 10:17 ZisZ 阅读(1658) 评论(0) 推荐(0) 编辑