自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(120)
  • 收藏
  • 关注

转载 [算法专题] stack

1. Convert Expression to Reverse Polish Notation http://www.lintcode.com/en/problem/convert-expression-to-polish-notation/ Given an expression string array, return the Polish notation of t...

2015-09-05 20:57:00 198

转载 [算法专题] Binary Tree

1 Same Tree https://leetcode.com/problems/same-tree/ Given two binary trees, write a function to check if they are equal or not. Two binary trees are considered equal if they are struct...

2015-08-30 19:06:00 193

转载 [Project] MiniSearch文本检索简介

1. 预处理过程 预处理主要用来事先生成程序在运行过程中可能用到的数据,以便加速处理时间。 预处理的过程主要生成程序所需的三个文件:网页库文件,网页位置信息文件和倒排索引文件。 网页库文件 其中网页库文件ripepage.lib主要是以格式化的数据存储大量的网页信息,每个网页的格式化数据为: <doc> <docid>id</docid...

2015-08-19 22:17:00 458

转载 [Project] SpellCorrect源码详解

该Project原来的应用场景是对电商网站中输入一个错误的商品名称进行智能纠错,比如iphoae纠错为iphone。以下介绍的这个版本对其作了简化,项目源代码地址参见我的github:https://github.com/jianxinzhou/MyProject_1/tree/uint32 。 该Project的主要思想是利用字符串编辑距离来实现拼写纠错。每当客户端来一个查询词,服务...

2015-08-18 19:33:00 183

转载 [算法专题] LinkedList

前段时间在看一本01年出的旧书《effective Tcp/Ip programming》,这个算法专题中断了几天,现在继续写下去。 Introduction 对于单向链表(singly linked list),每个节点有⼀个next指针指向后一个节点,还有一个成员变量用以储存数值;对于双向链表(Doubly LinkedList),还有一个prev指针指向前一个节点。与数组类似,...

2015-08-17 22:37:00 110

转载 理解Time-Wait

What is it? TIME-WAIT状态的主要作用在于TCP连接的拆除阶段。拆除一个TCP连接通常需要交换4个segment,如下图所示: Host1上的应用程序关闭了自己这一端的连接,使得TCP向Host 2发送了一个FIN。Host 2对这个FIN进行ACK,并将这个FIN作为一个EOF传送给应用程序(假设Host 2上的应用程序有一个挂起的read操作)。经过一段时间...

2015-08-14 21:52:00 101

转载 一些有价值的Blog推荐

待看的一些文章 1. 性能调优攻略 http://coolshell.cn/articles/7490.html 2. 内存的存储管理--段式和页式管理的区别 http://blog.sina.com.cn/s/blog_4c6403ed01000bbb.html 3. Linux信号相关笔记http://blog.csdn.net/dr8737010/article/detai...

2015-08-13 14:52:00 102

转载 [算法专题] BST&AVL&RB-Tree

BST 以下BST的定义来自于Wikipedia: Binary Search Tree, is a node-based binary tree data structure which has the following properties: The left subtree of a node contains only nodes with keys ...

2015-08-10 17:32:00 264

转载 [算法专题] 深度优先搜索&回溯剪枝

1. Palindrome Partitioning https://leetcode.com/problems/palindrome-partitioning/ Given a string s, partition s such that every substring of the partition is a palindrome. Return all po...

2015-08-07 21:59:00 158

转载 [算法专题] 二分搜索&排序数组

基础知识 二分非递归写法: int binary_search(const int a[], const int size, const int val) { int lower = 0; int upper = size-1; /* invariant: if a[i]==val for any i, then lower <= i <= ...

2015-08-04 20:00:00 188

转载 rand_1tom 产生 rand_1ton

给定一个等概率随机产生1~M的随机函数rand1ToM如下: public int rand1ToM(int m) { return (int) (Math.random() * m) + 1;}除此之外不能使用任何额外的随机机制。有两个输入参数分别为m和n,请用rand1ToM(m)实现等概率随机产生1~n的随机函数rand1ToN。Solution...

2015-08-01 13:56:00 232

转载 [LeetCode] Kth Largest Element in an Array

https://leetcode.com/problems/kth-largest-element-in-an-array/ Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth di...

2015-07-25 16:25:00 80

转载 进程控制(Note for apue and csapp)

1. Introduction We now turn to the process control provided by the UNIX System. This includes the creation of new processes, program execution, and process termination. We also look at the va...

2015-07-23 18:02:00 86

转载 Transport Layer Protocols

1 End-to-end Protocols(端到端协议) 传输层协议往往是主机对主机(host-to-host)或者说是端到端(end-to-end)。通常希望传输层协议可以提供如下service: 1. 保证资料可以成功传输给对方。例如TCP,就是一个非常可靠的protocol,在做文件传输时,必须保证100%正确,因此往往使用TCP。 2. 保证封包原来的顺序。在做文件传输时...

2015-06-23 22:34:00 421

转载 Internetworking

1 Introduction 所谓的InternetWorking就是将很多网络连接起来,那么在这种连接的网络下我们该如何传送封包呢? 2 IP and Routers 1 IP Datagram Header Format IP Address:目前IP地址均是32个bit,称为IPV4。未来会使用IPV6,128个bit。 Identification:Router本身...

2015-06-22 22:08:00 166

转载 Dynamic Programming | Set 4 (Longest Common Subsequence)

首先来看什么是最长公共子序列:给定两个序列,找到两个序列中均存在的最长公共子序列的长度。子序列需要以相关的顺序呈现,但不必连续。例如,“abc”, “abg”, “bdf”, “aeg”, ‘”acefg”等都是“abcdefg”的子序列。因此,一个长度为n的序列拥有2^n中可能的子序列(序列中的每一个元素只有选或者不选两种可能,因此是2^n)。 Example: LCS for i...

2015-06-18 22:24:00 98

转载 Dynamic Programming | Set 3 (Longest Increasing Subsequence)

在 Dynamic Programming | Set 1 (Overlapping Subproblems Property) 和 Dynamic Programming | Set 2 (Optimal Substructure Property) 中我们已经讨论了重叠子问题和最优子结构性质,现在我们来看一个可以使用动态规划来解决的问题:最长上升子序列(Longest Increas...

2015-06-18 21:45:00 81

转载 Dynamic Programming | Set 2 (Optimal Substructure Property)

正如我们在 Dynamic Programming | Set 1 (Overlapping Subproblems Property) 中讨论的那样,当一个问题具有以下2种性质时,建议使用动态规划来求解: 1 重叠子问题(Overlapping Subproblems) 2 最优子结构(Optimal Substructure) 我们已经在 Dynamic Programming...

2015-06-18 21:04:00 100

转载 Dynamic Programming | Set 1 (Overlapping Subproblems Property)

动态规划是这样一种算法范式:将复杂问题划分为子问题来求解,并且将子问题的结果保存下来以避免重复计算。如果一个问题拥有以下两种性质,则建议使用动态规划来求解。 1 重叠子问题(Overlapping Subproblems) 2 最优子结构(Optimal Substructure) 1 重叠子问题 类似于分治法,动态规划将子问题的解合并。当多次需要用到子问题的解时,应当考虑使用动...

2015-06-18 20:36:00 81

转载 [LintCode] Longest Increasing Continuous subsequence II

http://www.lintcode.com/en/problem/longest-increasing-continuous-subsequence-ii/# Give you an integer matrix (with row size n, column size m),find the longest increasing continuous subseque...

2015-05-26 16:03:00 48

转载 [LintCode] Longest Increasing Continuous subsequence

http://www.lintcode.com/en/problem/longest-increasing-continuous-subsequence/# Give you an integer array (index from 0 to n-1, where n is the size of this array),find the longest increasing...

2015-05-26 11:49:00 96

转载 [LintCode] Permutations II

Given a collection of numbers that might contain duplicates, return all possible unique permutations. For example, [1,1,2] have the following unique permutations: [1,1,2], [1,2,1...

2015-05-24 00:12:00 49

转载 [LintCode] Permutations

http://www.lintcode.com/en/problem/permutations/# Given a list of numbers, return all possible permutations. Example For nums = [1,2,3], the permutations are: [ [1,2,3], [1,3...

2015-05-22 22:34:00 60

转载 [LintCode] 拓扑排序

http://www.lintcode.com/zh-cn/problem/topological-sorting/# 给定一个有向图,图节点的拓扑排序被定义为: 对于每条有向边A--> B,则A必须排在B之前 拓扑排序的第一个节点可以是任何在图中没有其他节点指向它的节点 找到给定图的任一拓扑排序 solution ...

2015-05-22 21:20:00 82

转载 [LeetCode] Search in Rotated Sorted Array II

https://leetcode.com/problems/search-in-rotated-sorted-array-ii/ Follow up for "Search in Rotated Sorted Array": What if duplicates are allowed? Would this affect the run-time comple...

2015-05-22 19:18:00 53

转载 [LeetCode] Search in Rotated Sorted Array

https://leetcode.com/problems/search-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)....

2015-05-22 17:03:00 106

转载 [LeetCode] Search Insert Position

https://leetcode.com/problems/search-insert-position/ 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...

2015-05-22 11:57:00 47

转载 [LeetCode] word ladder II

http://www.lintcode.com/zh-cn/problem/word-ladder-ii/# 给出两个单词(start和end)和一个字典,找出所有从start到end的最短转换序列 比如: 每次只能改变一个字母。 变换过程中的中间单词必须在字典中出现。 样例 给出数据如下: ...

2015-05-21 19:24:00 74

转载 DFS遍历中forward、backward以及cross边的界定

再来看以下具体例子: 转载于:https://www.cnblogs.com/jianxinzhou/p/4515649.html

2015-05-19 21:50:00 107

转载 [LeetCode 127] Word Ladder

https://leetcode.com/problems/word-ladder/ http://www.lintcode.com/zh-cn/problem/word-ladder/ 给出两个单词(start和end)和一个字典,找到从start到end的最短转换序列 比如: 每次只能改变一个字母。 变换过程中的中间...

2015-05-19 18:55:00 64

转载 [NewCoder 7] 用两个栈实现队列

题目描述 用两个栈来实现一个队列,完成队列的Push和Pop操作。 队列中的元素为int类型。 水题,直接上代码: class Solution{public: void push(int node) { stack1.push(node); } int pop() { if (stack2.empty()) { ...

2015-05-11 12:38:00 92

转载 [LeetCode 3] Longest Substring Without Repeating Characters

https://leetcode.com/problems/longest-substring-without-repeating-characters/ Given a string, find the length of the longest substring without repeating characters. For example, the longest...

2015-05-10 21:57:00 49

转载 [NewCode 6] 重建二叉树

题目描述 输入某二叉树的前序遍历和中序遍历的结果,请重建出该二叉树。假设输入的前序遍历和中序遍历的结果中都不含重复的数字。例如输入前序遍历序列{1,2,4,7,3,5,6,8}和中序遍历序列{4,7,2,1,5,3,8,6},则重建二叉树并输出它的后序遍历序列。(测试用例中,"树"的输出形式类似于树的层次遍历,没有节点的用#来代替) 除了一些编译错误,一遍AC了,...

2015-05-10 19:34:00 80

转载 [NewCode 5] 从尾到头打印链表

题目描述 输入一个链表,从尾到头打印链表每个节点的值。 题目比较水,一遍就 AC 了,来看代码:/*** struct ListNode {* int val;* struct ListNode *next;* ListNode(int x) :* val(x), next(NULL) {* }* };*/...

2015-05-10 18:26:00 83

转载 [NewCode 4] 替换空格

题目描述 请实现一个函数,将一个字符串中的空格替换成“%20”。例如,当字符串为We Are Happy.则经过替换之后的字符串为We%20Are%20Happy。 最直接的方式,直接使用 STL。假设字符串的长度是n,那么对于每个空格字符,需要移动后面 o(n) 个字符,因此对含有 o(n) 个空格字符的字符串而言时间复杂度为 o(n2),过高了。代码如下: ...

2015-05-10 17:23:00 86

转载 [NewCoder 3] 二维数组中的查找

题目描述 在一个二维数组中,每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序。请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否含有该整数。 来分析下,假设在数组中随便找一个数字 inner_number 来与 target 进行比较,如果 target > inner_number,那么我们需要在数组中剔除掉 in...

2015-05-10 15:56:00 69

转载 [LeetCode 107] Binary Tree Level Order Traversal II

https://leetcode.com/problems/binary-tree-level-order-traversal-ii/ http://www.lintcode.com/zh-cn/problem/binary-tree-level-order-traversal-ii/# Given a binary tree, return the bottom-up...

2015-05-09 18:54:00 47

转载 [LeetCode 102] Binary Tree Level Order Traversal

https://leetcode.com/problems/binary-tree-level-order-traversal/ http://www.lintcode.com/zh-cn/problem/binary-tree-level-order-traversal/# Given a binary tree, return the level order tra...

2015-05-09 18:31:00 58

转载 [LeetCode 125] Valid Palindrome

https://leetcode.com/problems/valid-palindrome/ Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. For example, "A man, a...

2015-05-05 10:52:00 49

转载 Notes for Apue —— chapter 4 Files and Directories(文件和目录)

4.1 Introduction 4.2 stat, fstat, fstatat, and lstat Functions The lstat function is similar to stat, but when the named file is a symbolic link, lstat returns information about the symbolic ...

2015-05-04 21:57:00 117

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除