Apparently BFS is the most obvious one.. but it is not that simple - only constant extra space is provided.Then the only strategy to take is recursion...
分类:
其他好文 时间:
2014-07-22 00:39:35
阅读次数:
258
用G++过了,c++无限WA
就是一水,就是求输入的字符串中是否有一个是其他字符串的子串;
注意这种数据。。。
0000
010
01
9
字符串的长度从大到小;
#include
#include
#include
using namespace std;
char qq[20005];
struct node{
int q[2];
int w;
node...
分类:
其他好文 时间:
2014-07-22 00:30:36
阅读次数:
192
# include
# include
# include
using namespace std;
struct node
{
int pos;
int d;
int num;
friend bool operator n2.d;//仍的距离从小到大
return...
分类:
其他好文 时间:
2014-07-21 11:43:44
阅读次数:
180
# include
# include
# include
using namespace std;
struct node
{
int y;
int val;
int num;
friend bool operatorn2.num;//从小到大
return...
分类:
其他好文 时间:
2014-07-21 11:36:44
阅读次数:
203
Given a linked list, remove thenthnode from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After re...
分类:
其他好文 时间:
2014-07-21 09:02:01
阅读次数:
161
/*主要思路;
用一个链表存储数组信息,然后依次找出这个链表中最小的数字,然后插入到另外一个链表中,并删除原来链表中最小数字这个节点,一共循环n次,然后另外一个链表中的数字就是排序好的数组,依次输出即可;
*/
#include
using namespace std;
#include
class Node /...
分类:
其他好文 时间:
2014-07-20 22:47:23
阅读次数:
256
简单的二叉树的先根遍历模板的应用
class Solution:
# @param root, a tree node
# @return an integer
def hehe(self, num, root):
#再原来的基础上*10,再加上当前的root.val
num = num * 10 + root.val
...
分类:
其他好文 时间:
2014-07-20 22:45:33
阅读次数:
299
dfs 栈溢出,bfs超时,用dfs非递归就不溢出了,前后写了1一个星期class node{ int i; int j; public node(int i1,int j1) { i=i1; j=j1; ...
分类:
其他好文 时间:
2014-07-20 22:32:17
阅读次数:
244
采用一维数组建树。(因为一维数组建的是完全二叉树,时间上比用孩子节点指针建树慢,不过基本可以忽略=-=)
#include
#include
#include
using namespace std;
const int INF = 0xffffff0;
int minV=INF;
int maxV=-INF;
struct Node
{
int L,R;
int minV,ma...
分类:
其他好文 时间:
2014-07-20 22:28:44
阅读次数:
216
现在很多人估计和我一样项目中已经开始应用起nodeJS,而伴随着项目的需求,对nodejs版本也有着各种需求,好了直接进入主题,现在node版本管理网上有很多方式,这里说两种:
第一种module n:
sudo npm install n -g
//安装node管理模块n
sudo n 0.11.12
//安装node0.11.12版本
n
//安装完成之后,直接输入n后输出当...
分类:
其他好文 时间:
2014-07-20 22:11:43
阅读次数:
322