原题地址:https://oj.leetcode.com/problems/search-a-2d-matrix/题意:Write
an efficient algorithm that searches for a value in anmxnmatrix. This matrix has
the...
分类:
编程语言 时间:
2014-06-29 07:56:13
阅读次数:
321
K-Nearest Neighbors
The algorithm caches all training samples and predicts the response for a new sample by analyzing a certain number (K) of the nearest neighbors of the sample using voting, calcu...
分类:
其他好文 时间:
2014-06-20 11:51:33
阅读次数:
337
Bubble sortBubble sort, sometimes incorrectly
referred to as sinking sort, is a simple sorting algorithm that works by
repeatedly stepping through the...
分类:
其他好文 时间:
2014-06-07 11:30:59
阅读次数:
390
1. 普通的二分查找2. 查找最左边的值3. 查找最右边的值Worst case
performance: O(log n)Best case performance: O(1)Average case performance: O(log
n)Worst case space complexity...
分类:
其他好文 时间:
2014-06-07 11:19:48
阅读次数:
248
随机生成[0,n)中不重复的m个数。 1 class Random { 2 public: 3
Random(int n, int m):n(n), m(m) {} 4 void generate() { 5 srand(time(NULL)); 6
...
分类:
其他好文 时间:
2014-06-07 08:42:38
阅读次数:
178
算法导论上面快速排序的实现。代码:def partition(array, left, right):
i = left-1 for j in range(left, right): if array[j] <= array[right]: i += ...
分类:
编程语言 时间:
2014-06-06 18:18:13
阅读次数:
351
/** * jQuery MD5 hash algorithm function * * *
Calculate the md5 hash of a String * String $.md5 ( String str ) * * *
Calculates the MD5 ha...
分类:
Web程序 时间:
2014-06-05 21:50:52
阅读次数:
612
An iterative algorithm takes one step at a
time, ensuring that each step makes progress while maitining the loop
invariant.A paradigm shift:View an al...
分类:
其他好文 时间:
2014-06-02 19:20:20
阅读次数:
286
分析:
* 可以匹配任意个字符,包括0个多个连续的*的作用相当于1个*。* 后无其他字符,则直接匹配出现*p为 *,而*s为字符时,我们有两种选择,一种是跳过*p指示的*,也就是令*匹配0个字符,继续向后匹配。
一种是我们需要用* 匹配多个字符,才能完成匹配。
* 后有其他字符,则在s串中向后找与该非*字符匹配的字符,若没找到,则不匹配,若找到了,则会有不同的情况。
...
分类:
其他好文 时间:
2014-06-02 15:14:29
阅读次数:
271
Best Time to Buy and Sell Stock IISay you have
an array for which theithelement is the price of a given stock on dayi.Design an
algorithm to find the ...
分类:
其他好文 时间:
2014-06-02 15:01:53
阅读次数:
305