源码如下: template struct __is_pointer_helper : public false_type { }; template struct __is_pointer_helper : public true_type { }; /// is_p...
分类:
编程语言 时间:
2014-12-08 12:06:01
阅读次数:
200
Given a binary tree
struct TreeLinkNode {
TreeLinkNode *left;
TreeLinkNode *right;
TreeLinkNode *next;
}
Populate each next pointer to point to its next right node. If there is no next right node, the next pointer should be set t...
分类:
其他好文 时间:
2014-12-05 22:47:04
阅读次数:
271
这道题目很经典,很多书和OJ里都有。如果初次遇到,一定很难搞定。再看其解法,实在是很惊艳。
有两个可以得到深刻启示的地方:
(1)冗余的思想。谈到复制,我们往往都会另起炉灶,而不会原来链表上搞来搞去,感觉很复杂很危险,会一团糟。美错,最危险的地方就是最安全的地方。
(2)指针的步伐。这里的指针有一走两步的操作,很容易导致RE。但是否意味着每步都要仔细考虑指针越界?不然,那样程序会写的很累很乱...
分类:
其他好文 时间:
2014-12-05 12:50:51
阅读次数:
165
A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.Return a deep copy ...
分类:
其他好文 时间:
2014-12-03 13:47:22
阅读次数:
151
问题描述:
Given a binary tree
struct TreeLinkNode {
TreeLinkNode *left;
TreeLinkNode *right;
TreeLinkNode *next;
}
Populate each next pointer to point to its next right nod...
分类:
其他好文 时间:
2014-12-03 00:30:06
阅读次数:
198
【题目】
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,...
分类:
其他好文 时间:
2014-12-02 10:38:56
阅读次数:
170
It is another typical kernel panic due to invalid address.Panic log:[ 20.896935] c3 554 (netd) Unable to handle kernel NULL pointer dereference at v.....
分类:
其他好文 时间:
2014-12-01 12:43:30
阅读次数:
355
1 void levelOrder(Bitree* root){ 2 queue nodeQueue; 3 Node* pointer=root; 4 if(pointer){ 5 nodeQueue.push(pointer); 6 } 7 ...
分类:
其他好文 时间:
2014-11-26 22:28:44
阅读次数:
211
尽可能使用const
(1)const约束指针、迭代器
const char* p = "adc"; //non-const pointer,const data
char* const p = "abc"; //const pointer,non-const data
const char* const p = "abc";//const pointer,const data
const s...
分类:
编程语言 时间:
2014-11-26 20:59:52
阅读次数:
169
很明显的2 pointer问题。。。当满足条件的时候后面的指针加,不满足条件的时候前面的指针加,直到满足条件。。。class Solution {public: int lengthOfLongestSubstringTwoDistinct(string s) { int sta...
分类:
其他好文 时间:
2014-11-26 16:10:45
阅读次数:
336