上一页 1 ··· 7 8 9 10 11 12 13 下一页

2014年3月22日

Populating Next Right Pointers in Each Node

摘要: 1 //按说层次遍历最方便了,但是空间复杂度不满足题意 2 //遍历吧,可是像例子中的,5—>6怎么实现呢 3 //You may assume that it is a perfect binary tree (ie, all leaves are at the same level, and every parent has two children). 4 //这个提示是什么意思? 5 void connect(TreeLinkNode *root) { 6 if(root==NULL) 7 return;... 阅读全文

posted @ 2014-03-22 10:51 crane_practice 阅读(184) 评论(0) 推荐(0) 编辑

2014年3月21日

Pascal's Triangle

摘要: 1 vector > generate(int numRows) { 2 int i,j; 3 vector > intVV; 4 vector intV; 5 if(numRows >' 7 return intVV; 8 intV[0].push_back(1); 9 intVV[0].push_back(intV[0]);10 for(i=1;i > generate(int numRows) { 2 int i,j; 3 ... 阅读全文

posted @ 2014-03-21 23:01 crane_practice 阅读(198) 评论(0) 推荐(0) 编辑

Best Time to Buy and Sell Stock

摘要: 先说点股票的事,对股票一无所知,我问明哥,比如说我今天10元买了个股票,明天11元,后天12元,那我后天是不是赚了3元?他说不是,股票只有卖了才有钱,也就是说后天卖了的话,赚2元。一般都会提到的算法是分治和动态规划(《剑指offer》中的第一种方法也很好,容易理解),动态规划后面再去实现,看到http://blog.csdn.net/iammiaoyan/article/details/11730059中说的另外一种感觉容易被忽视的方法(虽然很常见):要求最大的收益,自然是用最高的股票价格减去最低的价格即可,考虑到时间的因素,当前的收益一定是当天价格减去前面几天里的最低价格即可。 1 ... 阅读全文

posted @ 2014-03-21 22:02 crane_practice 阅读(189) 评论(0) 推荐(0) 编辑

Java 对象和实例的区别

摘要: 本来我以为是一样的,其实是不一样的参看:http://www.blogjava.net/dreamstone/archive/2011/06/03/101733.html 阅读全文

posted @ 2014-03-21 13:28 crane_practice 阅读(277) 评论(0) 推荐(0) 编辑

2014年3月20日

java中抽象类跟接口的区别

摘要: 额,好吧,本来是打算转载些神马的,但是搜资料的过程中发现了一个专注与java的人,那就关注啦,以后多进他blog学习学习:http://www.cnblogs.com/chenssy/p/3376708.html就这个问题来说,这个写的也很不错:http://www.xl7788.com/zt/computerprogram/JavaInterface.htmlJava抽象类与接口一个软件设计的好坏,我想很大程度上取决于它的整体架构,而这个整体架构其实就是你对整个宏观商业业务的抽象框架,当代表业务逻辑的高层抽象层结构 合理时,你底层的具体实现需要考虑的就仅仅是一些算法和一些具体的业务实现了。当 阅读全文

posted @ 2014-03-20 22:25 crane_practice 阅读(212) 评论(0) 推荐(0) 编辑

2014年3月19日

Single Number II

摘要: 转自:http://blog.csdn.net/kenden23/article/details/136252971 int singleNumber(int A[], int n) { 2 for(int i = 0; i 3<2不成立,然后呢,就木有然后了 1 int singleNumber(int A[], int n) { 2 if(A==NULL||n<=0) 3 return 0; 4 //if(n<=2) 5 //return A[0]; 6 sort... 阅读全文

posted @ 2014-03-19 17:30 crane_practice 阅读(140) 评论(0) 推荐(0) 编辑

Single Number

摘要: 1 int singleNumber(int A[], int n) {2 if(A==NULL||n<=0)//这是个好习惯,防止程序崩溃3 return 0;4 int i;5 int result=A[0];6 for(i=1;i<n;++i)7 result ^= A[i];8 return result;9 } 阅读全文

posted @ 2014-03-19 15:23 crane_practice 阅读(92) 评论(0) 推荐(0) 编辑

2014年3月18日

Linked List Cycle II

摘要: 1 ListNode *detectCycle(ListNode *head) { 2 if(!head||!head->next) 3 return NULL; 4 ListNode *fast,*slow; 5 fast=head; 6 slow=head; 7 while(fast&&fast->next) 8 { 9 slow=slow->next;10 fast=fast->next->next;11 ... 阅读全文

posted @ 2014-03-18 21:20 crane_practice 阅读(108) 评论(0) 推荐(0) 编辑

Linked List Cycle

摘要: 1 bool hasCycle(ListNode *head) { 2 if(head==NULL) 3 return false; 4 ListNode *pBefore,*pLater; 5 if(head->next) 6 pBefore=head->next; 7 else 8 return false; 9 pLater=head;10 while(pBefore)11 {12 ... 阅读全文

posted @ 2014-03-18 17:29 crane_practice 阅读(535) 评论(0) 推荐(0) 编辑

2014年3月14日

字符串,字符数组(C/C++)

摘要: 这个地方困惑我好久了,废话不多说 char c1[]="12345"; char *c2="12345"; string c3="12345"; int a1=strlen(c1); int a2=strlen(c2); int a3=strlen(c3);//error: cannot convert 'std::string {aka std::basic_string}' to 'const char*' for argument '1' to 'size_t strlen 阅读全文

posted @ 2014-03-14 10:21 crane_practice 阅读(875) 评论(0) 推荐(0) 编辑

上一页 1 ··· 7 8 9 10 11 12 13 下一页

导航