两道lca模板题,用的是倍增法,nlogn预处理,logn查询。#include #include #include #include using namespace std;#define maxn 10100struct Edge{ int u,v,w,next;}e[100100];i...
分类:
其他好文 时间:
2014-09-25 20:24:27
阅读次数:
236
#include //单向循环链表实现与遍历typedef struct Node { int data; struct Node *next;} Node;int main (){Node n1 = {1, NULL}; Node n2 = {2, NULL}; Node n3 = {3, NUL...
分类:
其他好文 时间:
2014-09-24 23:50:07
阅读次数:
277
如何导出jar包右键工程->Export->Java->JAR file->Next->Next选中工程和工程中你要打包的内容,如果是Android的项目,需要把Manifest文件去掉。指定打包出的jar文件的名字。点击Finish即可。
分类:
其他好文 时间:
2014-09-24 23:34:07
阅读次数:
165
概念: 像一个普通的链表结点中,其中成员next通常是指向同类型结点的指针.这就约束了链表中结点必须是同一类型,从而整个链表都只能保存同一类型的数据。而异质链表则是让next指向任何一种类型,也包括存有其他类型值得结点。这里就采用模板的方式.数据结构:templatestruct hetero_no...
分类:
编程语言 时间:
2014-09-24 23:15:37
阅读次数:
258
使用STL中的next_permutation(opt1,opt2)函数更容易实现。opt1为数组头地址,opt2为数组长度。排列是按字典序的。当找到下一个排列时,返回真,否则返回假,此时,把原数组重排一次。#include #include #include using namespace std...
分类:
其他好文 时间:
2014-09-24 22:37:37
阅读次数:
131
#includeusing namespace std;struct LinkNode{ int value; LinkNode* next; LinkNode* pre;};LinkNode* createDoubleRoundLinkList(){ LinkNode* head...
分类:
其他好文 时间:
2014-09-24 22:20:17
阅读次数:
193
题目:
Populate each next pointer to point to its next right node. If there is no next right node, the next pointer should be set to NULL.
Initially, all next pointers are set to NULL.
You may...
分类:
其他好文 时间:
2014-09-24 21:04:58
阅读次数:
188
1 首先我们需要创建一个phone Extension target当然我们也必须知道Extension app必须在一个containg app内 我们从建立一个target开始
选择菜单 file->new->target
选择photo Editing Extension 点击next 添加名字 完成创建Photo Extension app
2 在...
分类:
其他好文 时间:
2014-09-24 20:05:27
阅读次数:
303
同num8一样,此题考查的是二叉树的中序遍历,即先左子树再节点再右子树、
使用迭代法时,采用将节点和左子树均压入栈的方法,当左子树为NULL时,将top节点弹出,并存入结果列表,将next指针指向该节点的右节点
代码如下:
/**
* Definition for binary tree
* struct TreeNode {
* int val;
* Tre...
分类:
其他好文 时间:
2014-09-24 20:04:07
阅读次数:
177
最近一段时间在看算法,发现实现链表有联众方法,本科的时候学习数据结构,对于链表来说,会先建立一个头结点,firstNode,而这个first结点本身是一个node,只不过值域为空,而next域则是指向随后的结点。而在Robert Sedgewick的算法书中,是另一种实现方法,first是一个指针....
分类:
其他好文 时间:
2014-09-24 20:00:37
阅读次数:
308