会员
周边
捐助
新闻
博问
闪存
赞助商
所有博客
当前博客
我的博客
我的园子
账号设置
简洁模式
...
退出登录
注册
登录
canexjtuzju
记录
Powered by
博客园
博客园
|
首页
|
新随笔
|
联系
|
订阅
|
管理
上一页
1
···
4
5
6
7
8
9
10
11
12
···
23
下一页
2014年8月31日
c++笔记--stl的hash_map
摘要: 以下内容是转载的:http://stlchina.huhoo.net/bin/view.pl/Main/STLDetailHashMap详细解说STL hash_map系列详细解说STL hash_map系列0 为什么需要hash_map1 数据结构:hash_map原理2 hash_map 使用2...
阅读全文
posted @ 2014-08-31 20:24 canexjtuzju
阅读(186)
评论(0)
推荐(0)
编辑
2014年8月30日
LeetCode--3Sum
摘要: 类似于2sum,先排序,然后从左开始遍历,计算a[i]后面的等于-a[i]的两个元素,注意去除重复元素 1 class Solution { 2 public: 3 vector > threeSum(vector &num) { 4 vector > res; 5 ...
阅读全文
posted @ 2014-08-30 22:39 canexjtuzju
阅读(140)
评论(0)
推荐(0)
编辑
2014年8月29日
九章算法--寻找数组波峰
摘要: 题目描述:一 个数组A[1..n],假设数组中没有任何相邻两数相等,满足A[1]A[n]。A[i]被称为波峰,当且仅当 A[i]>A[i-1]并且A[i]>A[i+1]。请找到数组中的一个波峰。假设数组中存在相邻相等的数,该怎么做?二分法寻找一个波峰,如果数组存在相邻相等的元素则必须O(n) 1 /...
阅读全文
posted @ 2014-08-29 09:52 canexjtuzju
阅读(943)
评论(0)
推荐(0)
编辑
2014年8月28日
c++笔记--父类和子类的转化问题
摘要: 以下二种情况是可以成立的:父类指针或者引用可以指向子类对象(指针解释的对象大小为基类大小,子类包含有基类)子类分割成基类对象(一只鸡一定是一个动物)以下二种情况不能成立:子类指针或者引用指向父类对象(指针解释的对象大小为子类大小,比基类要大,会出现不合法的内存访问)基类转化成子类(一个动物不一定是鸡...
阅读全文
posted @ 2014-08-28 21:18 canexjtuzju
阅读(284)
评论(0)
推荐(0)
编辑
c++笔记--函数重载(不合法的重载情况)
摘要: 在下面几种情况下不能视为重载:1、返回值不同的函数不能视为重载2、返回值是否为静态不能视为重载3、数组和指针int fun(int *ptr);int fun(int ptr[]); // redeclaration of fun(int *ptr)4、函数和函数指针void h(int ());v...
阅读全文
posted @ 2014-08-28 20:23 canexjtuzju
阅读(645)
评论(0)
推荐(0)
编辑
重新排列数组,使得负数后面跟着正数,O(1)的空间
摘要: 两种情况:可以打乱原始顺序;不可以打乱原始顺序下面代码未测试,只是build了一下 1 /************************************************************************* 2 > File Name: RearrangeArr...
阅读全文
posted @ 2014-08-28 10:23 canexjtuzju
阅读(847)
评论(0)
推荐(0)
编辑
2014年8月27日
LeetCode--Insert Interval
摘要: 其实可以O(n)的思路,如下 1 class Solution { 2 public: 3 vector insert(vector &intervals, Interval newInterval) { 4 // Start typing your C/C++ soluti...
阅读全文
posted @ 2014-08-27 21:41 canexjtuzju
阅读(209)
评论(0)
推荐(0)
编辑
LeetCode--Surrounded Regions
摘要: 1 class Solution { 2 public: 3 void solve(vector> &board) { 4 int m = board.size(); 5 if(m == 0) 6 return; 7 ...
阅读全文
posted @ 2014-08-27 21:06 canexjtuzju
阅读(160)
评论(0)
推荐(0)
编辑
LeetCode--Container With Most Water
摘要: 双指针 1 class Solution { 2 public: 3 int maxArea(vector &height) { 4 if(height.size() == 0 || height.size() == 1) 5 return 0; 6 ...
阅读全文
posted @ 2014-08-27 09:51 canexjtuzju
阅读(133)
评论(0)
推荐(0)
编辑
2014年8月25日
LeetCode--Permutation Sequence
摘要: 1 class Solution { 2 public: 3 string getPermutation(int n, int k) { 4 int fac[10]; 5 bool vis[10]; 6 memset(vis, 0, size...
阅读全文
posted @ 2014-08-25 14:06 canexjtuzju
阅读(123)
评论(0)
推荐(0)
编辑
上一页
1
···
4
5
6
7
8
9
10
11
12
···
23
下一页