Missing Ranges
Total Accepted: 510
Total Submissions: 2300
Given a sorted integer array where the range of elements are [lower,
upper] inclusive, return its missing ranges.
For example, giv...
分类:
其他好文 时间:
2014-12-31 10:06:44
阅读次数:
368
题目大意:
思路:一看各种后缀那就是后缀数组没跑了。
求出sa,height之后就可以乱搞了。对于height数组中的一个值,height[i]来说,这个值能够作为lcp值的作用域只在左边第一个比他小的位置到右边第一个比他小的位置。这个东西很明显可以倍增RMQ+二分/单调栈。
之后就是数学题了
Σlen[Ti] + len[Tj] = (len + 1) * len * (len ...
分类:
编程语言 时间:
2014-12-30 23:47:04
阅读次数:
499
文件下载在App应用中也用到很多,一般版本更新时多要用的文件下载来进行处理,以前也有看过很多大神有过该方面的博客,今天我也自己来实践一下,写的一般,还请大家多提意见,共同进步。主要思路:
1.多线程下载:
首先通过下载总线程数来划分文件的下载区域:利用int range = fileSize / threadCount;得到每一段下载量;每一段的位...
分类:
移动开发 时间:
2014-12-30 20:44:38
阅读次数:
216
If you want your code to work on iOS 7 as well as iOS 8 you should use one of the rangeOfString calls instead. Basically if the range returned has a length of zero, the substring is not there.
/* The...
分类:
其他好文 时间:
2014-12-30 19:07:04
阅读次数:
293
也是一大神器,起码以后不用敲线段树的求区间的线段树了。代码30行左右 ,效率肯定比线段书快不少还有为以后写在线的LCA算法做个铺垫。思路比较简单,这里引荐不少优秀的博文。http://community.topcoder.com/tc?module=Static&d1=tutorials&d2=lo...
分类:
其他好文 时间:
2014-12-30 16:45:48
阅读次数:
166
1.简介
函数是重用的程序段。它们允许你给一块语句一个名称,然后你可以在你的程序的任何地方使用这个名称任意多次地运行这个语句块。这被称为调用函数。我们已经使用了许多内建的函数,比如input()和range()。
2.函数的定义和调用
函数通过def关键字定义。def关键字后跟一个函数的标识符名称,然后跟一对圆括号。圆括号之中可以包括一些变量名,该行以冒号结尾...
分类:
编程语言 时间:
2014-12-30 11:46:12
阅读次数:
144
题目描述:
Given a sorted array of integers, find the starting and ending position of a given target value.
Your algorithm's runtime complexity must be in the order of O(log n).
If the target is...
分类:
其他好文 时间:
2014-12-29 12:14:25
阅读次数:
112
//1.创建一个NSRange结构体 表示范围 NSRange range = {4,5}; NSRange range2 = NSMakeRange(4, 5); NSString * strRange = NSStringFromRange(range)...
分类:
其他好文 时间:
2014-12-28 16:44:37
阅读次数:
144
Bucket Sort:Scenario:Work when keys are in a small range.Linked List.Algorithm(Stable):1. Walk through each item and enqueue each item into its approp...
分类:
其他好文 时间:
2014-12-28 07:04:22
阅读次数:
181
这里采用的是算法导论的划分方式: import random def partition(array, left, right): pivot = array[left] i = left #j left +1 -> right for j in range(left + 1, right + 1)...
分类:
编程语言 时间:
2014-12-27 22:55:47
阅读次数:
317