给定一个整数X和整数A0,A1,…,AN-1,后者已经预先排序并在内存中,求下标i使得Ai = X , 如果X不在数据中则返回i = -1 。明显的解法是从左往右扫描,花费线性时间。但是这个算法没有用到该表已经排序这个事实。折半检索(binary search,二分法检索)策略:/** * Perf...
分类:
其他好文 时间:
2014-07-16 23:25:47
阅读次数:
233
Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in or...
分类:
其他好文 时间:
2014-07-16 23:16:32
阅读次数:
156
curl http://xxx.com/address/addresslist\?search\=%40 --cookie oa_cookie=123 -s| node parss.js js 代码var jsdom = require('jsdom') ,fs = require('fs...
分类:
Web程序 时间:
2014-07-10 13:58:50
阅读次数:
161
Write an efficient algorithm that searches for a value in anmxnmatrix. This matrix has the following properties:Integers in each row are sorted from l...
分类:
其他好文 时间:
2014-07-10 12:37:21
阅读次数:
189
简介grep (global search regular expression(RE) and print out the line,全面搜索正则表达式并把行打印出来)是一种强大的文本搜索工具,它能使用正则表达式搜索文本,并把匹配的行打印出来。Unix的grep家族包括grep、egrep和fgr...
分类:
系统相关 时间:
2014-07-10 11:37:34
阅读次数:
402
1.基本结构:INNODB用leastrecentlyused(LRU)算法来管理他的buffer_pool。buffer_pool在内部被分隔为两个list.ayounglist和aoldlist.Younglist存储那些高频使用的缓存数据(默认占整个BUFFER的5/8)Oldlist存储那些低频使用的数据(默认占整个BUFFER的3/8)2.使用机制:当一个..
分类:
数据库 时间:
2014-06-28 06:06:25
阅读次数:
550
现象:以前一直正常的爬网突然无法顺利完成,总是在进行到某个部分就停滞不前。调查:在查看了log文件后,发现了这条错误06/24/2014 11:14:51.86 NodeRunnerQuery1-734f5ee7-2cc2- (0x0DD4) 0x14A0 Search C...
分类:
其他好文 时间:
2014-06-27 22:28:18
阅读次数:
262
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 ord...
分类:
其他好文 时间:
2014-06-27 22:25:10
阅读次数:
443
题目大意:
分析长度为n的子串有多少种。
思路分析:
对于没出现的字符,将其分配一个数字。
然后将子串看做一个nc进制的数。
然后hash判断。
#include
#include
#include
#include
#include
#include
using namespace std;
bool vis[26666666];
int val[30...
分类:
其他好文 时间:
2014-06-27 09:45:35
阅读次数:
184
Given a binary tree, determine if it is a valid binary search tree (BST).
Assume a BST is defined as follows:
The left subtree of a node contains only nodes with keys less than the node's key....
分类:
其他好文 时间:
2014-06-27 09:15:12
阅读次数:
196