Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. Example: divide and conquer, like merge sort, use t ...
分类:
其他好文 时间:
2018-09-23 16:31:43
阅读次数:
120
单纯减法不行,需要用到位运算。 a<<b表示 a*(2^b). LeetCode出现了令人惊恐的同一段代码不同运行时间的情况..... ...
分类:
其他好文 时间:
2018-09-15 01:17:39
阅读次数:
165
德语常用语 Lösen Problem der Abteilung. 求导。 Die Abteilung von 3x ist 3. 3x的导数是3 Lösen Problem des Integrals. 求积分 Das Integral von 3x ist 1.5x2+C. 3x的一重积分是1 ...
分类:
其他好文 时间:
2018-09-12 15:05:51
阅读次数:
132
#include #include #include #include using namespace std; const int N=2e4+5; const int INF=0x7fffffff; inline int read() { char c=getchar();int num=0; ... ...
分类:
其他好文 时间:
2018-09-12 12:00:50
阅读次数:
145
今天使用 numpy.true_divide 发现个有趣的事情, 下面的代码18、19行如果去掉,就会报下面的 RuntimeWarning RuntimeWarning 加上对除数是否为0的判断就可以了,是不是说明numpy有一个自动检查的过程? ...
分类:
其他好文 时间:
2018-09-06 20:02:09
阅读次数:
1395
有这样一段程序,fun会对整数数组A进行求值,其中Floor表示向下取整: fun(A) sum = 0 for i = 1 to A.length for j = i+1 to A.length sum = sum + Floor((A[i]+A[j])/(A[i]*A[j])) return s ...
分类:
其他好文 时间:
2018-09-01 12:18:41
阅读次数:
141
动态规划与贪心、分治的区别 贪心算法(Greed alalgorithm) 是一种在每一步选择中都采取在当前状态下最好或最优(即最有利)的选择,从而希望导致全局结果是最好或最优的算法。 分治算法(Divide and conquer alalgorithm) 字面上的解释是“分而治之”,就是把一个复 ...
分类:
编程语言 时间:
2018-08-31 14:02:31
阅读次数:
195
百度百科:归并排序(MERGE-SORT)是建立在归并操作上的一种有效的排序算法,该算法是采用分治法(Divide and Conquer)的一个非常典型的应用。将已有序的子序列合并,得到完全有序的序列;即先使每个子序列有序,再使子序列段间有序。若将两个有序表合并成一个有序表,称为二路归并。 归并操 ...
分类:
编程语言 时间:
2018-08-28 01:00:36
阅读次数:
218
树里的 divide and conquer 感觉和 post order traversal 就是一个东西,反正都是递归。 下面方法返回了 root ,也可以不返回,直接用 flatten 自己递归也行。 时间复杂度 O(nlogn) 空间复杂度 O(h) ...
分类:
其他好文 时间:
2018-08-26 01:10:35
阅读次数:
121
Given a integers x = 1, you have to apply Q (Q ≤ 100000) operations: Multiply, Divide. Input First line of the input file contains an integer T(0 incl ...
分类:
其他好文 时间:
2018-08-24 22:56:24
阅读次数:
272