自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

  • 博客(83)
  • 资源 (3)
  • 收藏
  • 关注

原创 入栈出栈问题

上面就是它的常见公式,很多问题都可以通过计算这个公式直接得到你想要的结果。比如给你了一个这样的题目:已知一个入栈序列为1,2,3,4,5,求所有可能的出栈序列总数有多少?简单的一算就知道了这个就相当于要计算C5 的值了,也许你已经知道答案了。那么我想问:你知道怎么去求出它的所有可能的序列而不是仅仅要出它的总数呢?此时,这个公式将显得无力。那么我们接下来分析一下该如何解决这个问题。当面对比较复杂抽象

2014-07-12 10:31:28 629

转载 布隆过滤器 (Bloom Filter)

布隆过滤器 (Bloom Filter)是由Burton Howard Bloom于1970年提出,它是一种space efficient的概率型数据结构,用于判断一个元素是否在集合中。在垃圾邮件过滤的黑白名单方法、爬虫(Crawler)的网址判重模块中等等经常被用到。哈希表也能用于判断元素是否在集合中,但是布隆过滤器只需要哈希表的1/8或1/4的空间复杂度就能完成同样的问题。布隆过滤器可以插入元

2014-04-06 19:24:42 572

原创 STL萃取

这个萃取着实不是很好理解,今天自己写了一段代码以至于自己都改了半天才输出想要的额济国

2014-04-05 20:29:23 690

转载 C语言结构体里的成员数组和指针

单看这文章的标题,你可能会觉得好像没什么意思。你先别下这个结论,相信这篇文章会对你理解C语言有帮助。这篇文章产生的背景是在微博上,看到@Laruence同学出了一个关于C语言的题,微博链接。微博截图如下。我觉得好多人对这段代码的理解还不够深入,所以写下了这篇文章。为了方便你把代码copy过去编译和调试,我把代码列在下面:123456

2014-04-05 10:11:48 670

原创 LRU Cache (LRU策略缓存)

Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set.get(key) - Get the value (will always be positive) of the key if

2014-03-28 15:13:21 607

原创 Surrounded Regions (包围区域)

Given a 2D board containing 'X' and 'O', capture all regions surrounded by 'X'.A region is captured by flipping all 'O's into 'X's in that surrounded region.For example,X X X XX O O XX X

2014-03-27 10:48:21 450

原创 Unix 文件目录与链接

4.1 stat函数与lstat函数的区别在于stat遇到参数为符号链接则会返回原始的被链接的文件的信息,而lstat函数会返回链接文件本身的信息。4.2 umask为777的时候表示所有用户(自己,组,其他)文件没有任何访问权写(读写执行)4.5 目录的大小一定不为0, 至少包含了.和..两个目录,符号链接文件的大小为被链接文件的名字长度(字节)也至少为1

2014-03-24 15:40:28 373

原创 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 fol

2014-03-24 14:05:42 507

原创 Binary Tree Zigzag Level Order Traversal (之字访问树节点)

Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between).For example:Given binary tr

2014-03-22 19:33:57 659

原创 Recover Binary Search Tree (恢复一棵二叉搜索树)

Two elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Note:A solution using O(n) space is pretty straight forward. Could you devise a

2014-03-22 10:06:11 704

原创 Flatten Binary Tree to Linked List(平整二叉树)

Given a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / \ \ 3 4 6The flattened tree should look like: 1 \

2014-03-20 18:33:54 556

原创 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-03-19 16:01:29 629

原创 Trapping Rain Water (最大盛水量)

Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.For example, Given [0,1,0,2,1,0,1,3,2,1,2,1],

2014-03-18 15:27:53 361

原创 windows环境下static变量的初始化

前几天有看到这么一个问题 说 c++中 static变量的初始化是什么时候, 和室友讨论了一下无果 做了一下实验,发现了一些结论。如果声明了一个static变量,但是没给这个变量赋值, 然后程序运行的时候也没有调用这个static变量,那么这个static变量实际上并没有被分配内存空间,也没有初始化,而被赋予处置了的static变量在main函数执行之前其实就已经分配了内存空间,下图所示变量b

2014-03-17 21:10:16 958

原创 Valid Sudoku (九宫格)

Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules.The Sudoku board could be partially filled, where empty cells are filled with the character '.'.A partially fille

2014-03-17 20:53:02 597

转载 C++项目中的extern "C" {}

引言在用C++的项目源码中,经常会不可避免的会看到下面的代码:123456789#ifdef __cplusplusextern "C" {#endif /*...*/ #ifdef __cplusplus}

2014-03-10 16:03:06 515

原创 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-03-10 10:53:17 445

原创 Length of Last Word(最后一个单词长度)

Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.If the last word does not exist, return 0.Note: A word is

2014-03-10 10:00:40 593

原创 Set Matrix Zeroes(矩阵置0)

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(m

2014-03-10 08:36:19 542

原创 Longest Common Prefix (最长公共前缀)

Write a function to find the longest common prefix string amongst an array of strings.求一个字符串数组中的所有字符串的最长公共前缀,这个就一个一个字符串从头比较就行了。class Solution {public: string longestCommonPrefix(vector &s

2014-03-07 10:25:19 1974

原创 Validate Binary Search Tree (判断一颗树是否为二叉排序树)

Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *

2014-03-07 09:47:19 529

原创 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.题意是说给定一个k >= 0 把链表循环右移k位, 这

2014-03-06 10:36:08 994

原创 Construct Binary Tree from Inorder and Postorder Traversal(根据中序后序建立二叉树)

Given inorder and postorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.这个根据中序和后序建立二叉树与根据先序中序建立非常像,只需要把从先序从头开始扫描变成从后序的尾部

2014-03-06 09:53:14 706

原创 Construct Binary Tree from Preorder and Inorder Traversal (先序中序建立二叉树)

Given preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.给定先序序列和中序序列建立二叉树, 递归解决, 按顺序扫描先序序列,每一次扫描的第一个节点作为根,然后在中序序

2014-03-06 09:31:44 640

原创 Palindrome Number (数字回文)

Determine whether an integer is a palindrome. Do this without extra space.click to show spoilers.Some hints:Could negative integers be palindromes? (ie, -1)If you are thinking of convertin

2014-03-05 17:03:38 514

原创 Convert Sorted List to Binary Search Tree (有序链表转换成平衡二叉排序树)

Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.题目描述很简单,就是说把一个升序链表转换成平衡二叉排序树,即 最优二叉排序树, 最优二叉排序树的搜索时间为logn 即树的高度, 因为链表很难处理,直接转换成数组比较容易

2014-03-05 10:29:54 564

原创 Valid Palindrome(有效回文)

Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a plan, a canal: Panama" is a palindrome."race a car" is not a

2014-03-05 09:51:28 628

原创 Path Sum (路径和)

Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.For example:Given the below binary tree and sum

2014-03-04 16:25:40 497

原创 Insertion Sort List(链表插入排序)

Sort a linked list using insertion sort.这里给单链表进行插入排序,个人想到两种方法 一种是交换节点的指针,一种是交换节点的值,前者要判断头节点,感觉比较麻烦,就用了交换值的方法, 通常的插入排序是在插入点的位置依次与前面的元素相比较,如果比前面的小,就把当前的位置的值变成前一个位置的值,最后得到的是最终插入位置, 这里单链表没办法往前搜索,那么就从头

2014-03-04 15:38:45 670

原创 Plus One (加一)

Given a non-negative number represented as an array of digits, plus one to the number.The digits are stored such that the most significant digit is at the head of the list.这个题就不说了,加法操作。。

2014-03-04 14:24:18 499

原创 Binary Tree Postorder Traversal (二叉树后序遍历 非递归)

Given a binary tree, return the postorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [3,2,1].Note: Recursive solut

2014-03-04 10:04:40 505

原创 Binary Tree Preorder Traversal(二叉树先序遍历)

阔别了已久的leetcode 又回来了。Given a binary tree, return the preorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [1,2,3].

2014-03-03 20:41:51 570

原创 基于lucene的搜索引擎

长时间没写点东西了,突然想写个搜索引擎,看看时间如果允许的话就来做个完整点的。这里操作系统win7 64bit   环境 lucene4.6.1 , eclipse配置的时候只要把lucene中的jar文件都添加到b

2014-02-25 19:38:23 484

原创 Opencv学习(二) 视频读取

做完图像读取再来做一下视频读取,这里不知道为什么程序写好后出现找不到dll的错误 这个dll名字是libiconv-2.dll 后来在网上找了一个 然后下载到了opencv的bin目录中我的目录是 D:\opencv\build\x86\vc10\bin 下载地址是http://www.jb51.net/dll/libiconv-2.dll.html#down然后就好了哦 对还有好

2013-11-21 13:40:48 1531

原创 出于个人兴趣 学习一下opencv(一)

由于lab的情况略让人头痛,以及偶然,我决定学习一下opencv,一方面作为动手练习,一方面了解下图形图像处理方面的知识。安装什么的就不写了 网上太多 这里环境是vs2010+opencv2.47 语言使用C++结构:opencv主要由以下几个模块构成:cxcore, cv, ml(machine learning), highgui, cvauxcxcore.h

2013-11-21 09:49:07 1249

原创 Longest Substring Without Repeating Characters (求最长不重复子串)

Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3. Fo

2013-10-30 09:25:24 540

原创 Minimum Depth of Binary Tree (二叉树最小高度)

Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.对于给定的二叉树,求最小高度(最小高度为根节点到最近的叶子节点的

2013-10-30 08:47:54 826

原创 Linked List Cycle (链表是否有环)

Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?快慢指针。步长为1,2/** * Definition for singly-linked list. * struct ListNode { *

2013-10-29 21:17:53 502

原创 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

2013-10-29 10:48:20 495

原创 Container With Most Water (最大盛水量)

Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Fin

2013-10-29 10:04:28 1162

2012 考研外部排序

关于2012年考研 外部排序和其他新增知识点内容 与人玫瑰 手留余香

2011-12-18

2012年_天勤计算机考研模拟题(二).pdf

2012年_天勤计算机考研模拟题(二).pdf 考研学子的福音 与人玫瑰 手留余香

2011-12-18

空空如也

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

TA关注的人

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