- 博客(103)
- 资源 (10)
- 收藏
- 关注
原创 17. Letter Combinations of a Phone Number
Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephone buttons) is given below.Input:Digi
2016-07-31 20:42:56 384
转载 Boost智能指针——scoped_ptr
boost::scoped_ptr和std::auto_ptr非常类似,是一个简单的智能指针,它能够保证在离开作用域后对象被自动释放。下列代码演示了该指针的基本应用:#include #include #include class implementation{public: ~implementation() { std::cout
2016-07-30 17:35:03 397
转载 extern C的作用详解
extern "C"的主要作用就是为了能够正确实现C++代码调用其他C语言代码。加上extern "C"后,会指示编译器这部分代码按C语言的进行编译,而不是C++的。由于C++支持函数重载,因此编译器编译函数的过程中会将函数的参数类型也加到编译后的代码中,而不仅仅是函数名;而C语言并不支持函数重载,因此编译C语言代码的函数时不会带上函数的参数类型,一般之包括函数名。 这个功能十分有
2016-07-30 17:28:30 2032
转载 设计模式:观察者模式
http://www.cnblogs.com/li-peng/archive/2013/02/04/2892116.html今天介绍另一种模式观察者模式是我们经常用的一个模式,比如在用wcf做服务的时候通知客户端做一些操作一般用设计者模式。今天做一个订报纸的小例子来理解一下观察者模式 出版者+订阅者=观察者模式
2016-07-30 16:31:32 344
转载 diff
如果两个文件相似度很高,那么上下文格式的diff,将显示大量重复的内容,很浪费空间。1990年,GNU diff率先推出了"合并格式"的diff,将f1和f2的上下文合并在一起显示。它的使用方法是加入u参数(代表unified)。 $ diff -u f1 f2显示结果如下: --- f1 2012-08-29 16:45:41.000000000
2016-07-30 15:09:39 405
原创 二分查找总结
1.查找插入位置 搜索插入位置:Search Insert Position2.查找前后界 搜索一个区间:Search for a Range3.旋转有序数组找最小值(包括无重复值和有重复值) Find Minimum in Rotated Sorted Array(重要!!!)4.旋转有序数组找某一个值(
2016-07-29 16:45:29 344
原创 Search in Rotated Sorted Array
1.33. Search in Rotated Sorted ArraySuppose 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).You are given a target va
2016-07-29 16:34:19 443
转载 数据库为什么要用B+树结构--MySQL索引结构的实现
为什么使用B+树?言简意赅,就是因为:1.文件很大,不可能全部存储在内存中,故要存储到磁盘上2.索引的结构组织要尽量减少查找过程中磁盘I/O的存取次数(为什么使用B-/+Tree,还跟磁盘存取原理有关。)3.局部性原理与磁盘预读,预读的长度一般为页(page)的整倍数,(在许多操作系统中,页得大小通常为4k)4.数据库系统巧妙利用了磁盘预读原理,将一个节点的大小设为等于一个页,这样
2016-07-29 15:09:01 2583
转载 c++ 中的fill 和memset
fill 的头文件是 命名空间是std; 用法: eg: #include using namespace std; int main() { char s[100]; fill(s,s+100,'a'); for(int i=0;i cout cout
2016-07-29 15:05:34 1652
原创 63. 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
2016-07-28 22:19:48 345
原创 147. Insertion Sort List
Sort a linked list using insertion sort./** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */
2016-07-28 21:20:37 329
转载 mysql 数据库引擎
三、MySQL数据库引擎类别 你能用的数据库引擎取决于mysql在安装的时候是如何被编译的。要添加一个新的引擎,就必须重新编译MYSQL。在缺省情况下,MYSQL支持三个引擎:ISAM、MYISAM和HEAP。另外两种类型INNODB和BERKLEY(BDB),也常常可以使用。ISAM ISAM是一个定义明确且历经时间考验的数据表格管理方法,它在设计之时就考虑到
2016-07-28 15:35:58 589
原创 86. 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
2016-07-27 17:36:29 321
原创 50. Pow(x, n) 372. Super Pow
1.50. Pow(x, n)Implement pow(x, n).注意要考虑n为负数的情况。class Solution {public: double myPow(double x, int n) { double res = 1; unsigned int newn = n; if (n < 0) { x = 1 / x; newn = -n;
2016-07-27 16:42:28 482
转载 图像旋转算法与实现
好吧,先下个定义,图像旋转是指图像以某一点为中心旋转一定的角度,形成一幅新的图像的过程。当然这个点通常就是图像的中心。既然是按照中心旋转,自然会有这样一个属性:旋转前和旋转后的点离中心的位置不变.根据这个属性,我们可以得到旋转后的点的坐标与原坐标的对应关系。由于原图像的坐标是以左上角为原点的,所以我们先把坐标转换为以图像中心为原点。假设原图像的宽为w,高为h,(x0,y0)为原坐标内的一点
2016-07-26 23:07:09 701
转载 [转载]图像缩放的双线性内插值算法的原理解析【转】
越是简单的模型越适合用来举例子,我们就举个简单的图像:3X3 的256级灰度图,也就是高为3个象素,宽也是3个象素的图像,每个象素的取值可以是 0-255,代表该像素的亮度,255代表最亮,也就是白色,0代表最暗,即黑色 。假如图像的象素矩阵如下图所示(这个原始图把它叫做源图,Source):234 38 2267 44 1289 65 63
2016-07-26 23:00:18 380
原创 142. Linked List Cycle II
Given a linked list, return the node where the cycle begins. If there is no cycle, return null.Note: Do not modify the linked list.Follow up:Can you solve it without using extra space?
2016-07-26 21:56:30 235
原创 368. Largest Divisible Subset(重点)
Given a set of distinct positive integers, find the largest subset such that every pair (Si, Sj) of elements in this subset satisfies: Si % Sj = 0 or Sj% Si = 0.If there are multiple solutions
2016-07-26 21:39:18 1131
原创 120. Triangle
Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the following triangle[ [2], [3,4], [
2016-07-26 20:59:47 226
原创 201. Bitwise AND of Numbers Range
Given a range [m, n] where 0 For example, given the range [5, 7], you should return 4.[5, 7]里共有三个数字,分别写出它们的二进制为:101 110 111相与后的结果为100,仔细观察我们可以得出,最后的数是该数字范围内所有的数的左边共同的部分,如果上面那个例子不
2016-07-26 20:28:15 213
原创 114. 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
2016-07-25 21:38:12 1476
转载 android - JNI - 一维数组、二维数组的访问与使用
在JNI中访问JAVA类中的整型、浮点型、字符型的数据比较简单,举一个简单的例子,如下:[java] view plain copy//得到类名 jclass cls = (*env)->GetObjectClass(env, obj); //得到Java类中的变量Number jfieldID fNumber = (*en
2016-07-25 19:15:20 3600
转载 使用JNI进行Java与C/C++语言混合编程(1)--在Java中调用C/C++本地库
JNI系列文章索引使用JNI进行Java与C/C++语言混合编程(1)--在Java中调用C/C++本地库使用JNI进行Java与C/C++语言混合编程(2)--在C/C++中调用Java代码JNI是Java Native Interface的英文缩写, 中文翻译为本地调用, 自从Java 1.1开始就成为了Java标准的一部分.C/C++是系统级的
2016-07-25 19:05:38 1480
原创 78. Subsets 90. Subsets II
78. SubsetsGiven a set of distinct integers, nums, return all possible subsets.Note: The solution set must not contain duplicate subsets.For example,If nums = [1,2,3], a solution is:
2016-07-22 12:22:40 367
原创 331. Verify Preorder Serialization of a Binary Tree(难)
One way to serialize a binary tree is to use pre-order traversal. When we encounter a non-null node, we record the node's value. If it is a null node, we record using a sentinel value such as #.
2016-07-22 11:46:48 712
原创 33. 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).You are given a target value to search. If found in the array retur
2016-07-21 22:22:44 372
原创 274. H-Index(难)
Given an array of citations (each citation is a non-negative integer) of a researcher, write a function to compute the researcher's h-index.According to the definition of h-index on Wikipedia: "A
2016-07-21 12:07:39 291
原创 279. Perfect Squares(难)
Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n.For example, given n = 12, return 3 because 12 = 4 + 4 + 4; given n =
2016-07-20 23:01:12 278
原创 162. Find Peak Element(重要)
A peak element is an element that is greater than its neighbors.Given an input array where num[i] ≠ num[i+1], find a peak element and return its index.The array may contain multiple peaks, in
2016-07-20 22:15:34 359
原创 284. Peeking Iterator
Given an Iterator class interface with methods: next() and hasNext(), design and implement a PeekingIterator that support the peek()operation -- it essentially peek() at the element that will be r
2016-07-20 21:33:33 221
原创 73. 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.第一行和第一列记录每一列和每一行是否出现过0。另外用两个变量记录第一行和第一列是否出现过0.class Solution {public: void setZeroes(vector >&
2016-07-20 17:54:04 421
原创 74. Search a 2D Matrix
Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted from left to right.The first integer of each
2016-07-20 16:59:17 250
原创 215. 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 distinct element.For example,Given [3,2,1,5,6,4] and k = 2, return 5.
2016-07-20 16:34:03 237
原创 334. Increasing Triplet Subsequence
Given an unsorted array return whether an increasing subsequence of length 3 exists or not in the array.Formally the function should:Return true if there exists i, j, k such that arr[i] ar
2016-07-20 15:36:39 576
原创 75. Sort Colors
Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue.Here, we will use the integers
2016-07-19 22:38:35 329
原创 Number of Connected Components in an Undirected Graph 无向图中的连通区域的个数
Given n nodes labeled from 0 to n - 1 and a list of undirected edges (each edge is a pair of nodes), write a function to find the number of connected components in an undirected graph.Example 1:
2016-07-19 21:17:53 693
原创 11. 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,
2016-07-19 17:15:08 290
原创 300. Longest Increasing Subsequence(good!)
Given an unsorted array of integers, find the length of longest increasing subsequence.For example,Given [10, 9, 2, 5, 3, 7, 101, 18],The longest increasing subsequence is [2, 3, 7, 101], ther
2016-07-19 16:37:40 420
原创 48. Rotate Image(重要)
You are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?/* * clockwise rotate * first reverse up to dow
2016-07-19 16:02:20 219
原创 313. Super Ugly Number
Write a program to find the nth super ugly number.Super ugly numbers are positive numbers whose all prime factors are in the given prime list primes of size k. For example, [1, 2, 4, 7, 8, 13,
2016-07-18 22:45:14 239
Win7平台VS2010安装Visual Assist X
2015-03-20
合工大操作系统课程设计:基于内存的文件系统
2013-07-07
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人