- 博客(149)
- 资源 (1)
- 收藏
- 关注
原创 AC算法初探
AC算法初探一、什么是AC算法AC算法,即Aho-Corasick自动机算法。 该算法一次遍历原串便可定位所有模式串在原串中出现的位置。该算法通过所有的模式串构建一个有限状态自动机,然后用这个自动机去处理原串。
2015-08-16 11:20:13 972
转载 c++ 时间类型详解 time_t
http://blog.csdn.net/love_gaohz/article/details/6637625
2015-07-08 16:18:35 695
原创 题目1384:二维数组中的查找
题目描述:在一个二维数组中,每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序。请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否含有该整数。输入:输入可能包含多个测试样例,对于每个测试案例,输入的第一行为两个整数m和n(1输入的第二行包括一个整数t(1接下来的m行,每行有n个数,代表题目所给出的m行n列的矩阵(矩阵如题目描述所示,每一
2015-03-04 17:05:38 492
原创 leetcode--Reverse Nodes in k-Group
Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it is.
2015-02-22 12:56:54 458
原创 Leetcode--Merge k Sorted Lists
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.Hide Tags Divide and Conquer Linked List HeapHave you met this question in a
2015-02-19 11:31:49 415
原创 Leetcode--Remove Duplicates from Sorted List II
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.For example,Given 1->2->3->3->4->4->5, return 1->2->5.Given 1->1->1
2014-12-16 16:58:33 366
原创 C++对象模型 第六章 执行期语意学
第六章 执行期语意学1)munch策略:一个可移植但成本颇高的静态初始化(以及内存释放)方法,称它为munch。一个munch策略包括①为每一个需要静态初始化的文件产生一个_sti()函数,内含必要的constructor函数。②在每一个需要静态的内存释放操作的文件中,产生一个std()函数③一个可以调用_sti()函数的_main()函数int main(){_main();/
2014-12-09 09:59:13 479
原创 C++对象模型 第五章 构造、析构、拷贝语意学
第五章 构造、析构、拷贝语意学1)构造析构的顺序例:class A{public:A(int a=0):_a(a){cout~A(){coutprivate:int _a;};class C{public:C(int c=0):_c(c){cout~C(){coutprivate:int _c;};class B:publi
2014-12-06 17:23:09 557
原创 C++ 对象模型 第四章 函数语意学
1)静态成员函数不能声明为const也不能声明为虚函数,它不能直接访问非static数据成员。2)名称特殊处理(name mangling),一般而言,member的名称前加上class名称,形成独一无二的命名。但如果你声明(extern “C”)就会抑制nonmember function的mangling效果3)如果normalize()是一个virtual memb
2014-12-03 23:53:58 480
原创 C++对象模型 第三章 Data语意学
1)类的大小class X{}; class Y:virtual public X{}; class Z:virtual public X{}; class A:public Y,public Z{}; 大小分别为1 4 4 8下面计算sizeof(A)class X的大小(“编译器有无特殊处理”,有特殊处理就是0)base class y的大小减
2014-12-03 14:30:42 389
原创 C++对象模型 第二章 构造函数语意学
1)explict主要用于修饰构造函数,能够制止“单一参数的constructor”被当做一个conversion运算符。class myclass{public:myclass(int num);}myclass obj=10;//ok,convert int to myclass2)默认构造函数的构造操作“默认构造函数在需要的时候被编译器产生出来
2014-12-01 23:52:28 434
原创 Gas Station
There are N gas stations along a circular route, where the amount of gas at station i is gas[i].You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from station i to it
2014-11-14 20:48:37 407
原创 Leetcode--Jump Game II
Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Your goal is to
2014-11-14 13:59:01 448
原创 Leetcode--Jump Game
Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Determine if yo
2014-11-13 13:35:18 454
原创 Leetcode--Combination Sum II
Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.Each number in C may only be used once in the combinati
2014-11-13 12:29:48 561
原创 Leetcode--Multiply Strings
Given two numbers represented as strings, return multiplication of the numbers as a string.Note: The numbers can be arbitrarily large and are non-negative.Hide Tags Math String
2014-11-12 14:13:51 801
原创 C++ 对象模型 第一章 关于对象
补充:全局变量 (所有文件可见)静态全局变量(当前文件可见)局部变量(当前Scope可见)类的继承关系中的虚继承(virtual)就是共享的意思、纯虚函数:只能用于继承,它的实现留给该基类的派生类去做。内联函数(inline function)在计算机中,内联函数是一种程序语言结构,用来建议编译器对一些特殊函数进行内联扩展;也就是说建议编译器将指定的函数体插
2014-11-10 10:40:06 464
原创 UDP 用户数据报协议、DNS 域名系统
OSI 七层协议1)应用层:直接为用户的应用进程提供服务2)传输层:两个主机进程之间的通信提供服务 a)TCP:面向连接的,数据传输的单位是报文段,能够提供可靠的交付 b)UDP:无连接的,数据传输的单位是用户数据报,只能提供“尽最大努力交付”3)网络层:“分组”和“数据报”4)数据链路层:数据链路层将网络层交下来的IP数据报组装成帧和必要的控制信息5)
2014-11-10 10:20:06 1533
原创 Spiral Matrix II
Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order.For example,Given n = 3,You should return the following matrix:[ [ 1, 2, 3 ], [ 8, 9, 4 ], [
2014-11-05 19:44:36 450
原创 Spiral Matrix
Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.For example,Given the following matrix:[ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ]]You
2014-11-05 15:17:01 491
原创 Partition List
Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.You should preserve the original relative order of the nodes in each of t
2014-11-05 10:28:39 382
原创 Reverse Linked List II
Reverse a linked list from position m to n. Do it in-place and in one-pass.For example:Given 1->2->3->4->5->NULL, m = 2 and n = 4,return 1->4->3->2->5->NULL.Note:Given m, n satisfy the follo
2014-11-04 11:19:48 402
原创 TCP的交互式数据流、TCP的成块数据流、TCP超时和重传、TCP坚持定时器、TCP保活定时器
TCP的交互式数据流1)经受时延的确认TCP的交互式数据流通常使用“经过时延的确认”技术。通常服务器在接收到从客户端发送过来的数据时,并不马上发送ACK,而是等一小段时间,看看本机是否有数据要反馈给客户端,如果有,就将数据包含在此ACK包中,一起发送给Client。一般情况下这个时延为200ms。需要注意的时这个200ms的定时器时相对于内核的时钟滴答的。如果一个数据分
2014-11-04 10:34:25 1048
原创 Leecode--Set Matrix Zeroes
Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place.click to show follow up.Follow up:Did you use extra space?A straight forward solution using O(mn) s
2014-11-02 14:45:18 649
原创 Leetcode--Search for a Range
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 not found in t
2014-11-01 20:53:48 460
原创 Unique Paths II
Follow up for "Unique Paths":Now consider if some obstacles are added to the grids. How many unique paths would there be?An obstacle and empty space is marked as 1 and 0 respectively in the grid
2014-11-01 14:26:50 363
原创 Unique Paths
A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to reach the bo
2014-11-01 14:05:27 398
转载 Linux文件锁
一、文件锁的类型Linux 支持的文件锁技术主要包括劝告锁(advisory lock)和强制锁(mandatory lock)这两种。此外,Linux 中还引入了两种强制锁的变种形式:共享模式强制锁(share-mode mandatory lock)和租借锁(lease)。注意:
2014-10-30 20:23:45 666
原创 Leetcode--Minimum Path Sum
Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.Note: You can only move either down or right at a
2014-10-28 22:46:22 653 2
原创 Leetcode--Sum Root to Leaf Numbers
Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number.An example is the root-to-leaf path 1->2->3 which represents the number 123.Find the total
2014-10-28 21:39:41 384
原创 Leetcode--Combination Sum
Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.The same repeated number may be chosen from C unlimited number
2014-10-28 21:21:13 557
原创 Leetcode--Remove Duplicates from Sorted Array II
Follow up for "Remove Duplicates":What if duplicates are allowed at most twice?For example,Given sorted array A = [1,1,1,2,2,3],Your function should return length = 5, and A is now [1,1,2,2,
2014-10-27 22:38:35 398
原创 Leetcode--Remove Duplicates from Sorted Array
Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this in place with c
2014-10-27 22:06:57 629
原创 Leetcode--Find Minimum in Rotated Sorted Array
Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).Find the minimum element.You may assume no duplicate exists in the ar
2014-10-27 15:34:05 351
原创 Leetcode--Rotate List
Given a list, rotate the list to the right by k places, where k is non-negative.For example:Given 1->2->3->4->5->NULL and k = 2,return 4->5->1->2->3->NULL.Hide Tags Linked List Two Point
2014-10-26 19:07:42 432
原创 Leecode--Subsets II
Given a collection of integers that might contain duplicates, S, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set must not contain duplica
2014-10-26 13:23:29 364
原创 Leetcode--Subsets
Given a set of distinct integers, S, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set must not contain duplicate subsets.For example,
2014-10-26 12:50:01 337
原创 Leetcode--Combinations
Given two integers n and k, return all possible combinations of k numbers out of 1 ... n.For example,If n = 4 and k = 2, a solution is:[ [2,4], [3,4], [2,3], [1,2], [1,3], [1,4],]
2014-10-25 15:36:50 417
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人