题意:给定一棵二叉树,返回按层遍历的结果
思路1:bfs,定义一个新的struct,记录指针向节点的指针和每个节点所在的层
复杂度1:时间O(n),空间O(n)
思路2:dfs
递归函数:
void levelOrder(TreeNode *root, int level, vector<vector >&result)
表示把根为root的树按层存放在result中,其中level表示当前的层数
复杂度2:时间O(n),空间O(n)
相关题目:...
分类:
其他好文 时间:
2014-05-15 14:46:06
阅读次数:
355
创建表:
hive> CREATE TABLE pokes (foo INT, bar STRING);
Creates a table called pokes with two columns, the first being an integer and the other a string
创建一个新表,结构与其他一样
hive> create table n...
分类:
其他好文 时间:
2014-05-15 07:07:58
阅读次数:
303
题意:判断一个链表中是否有环
思路:快慢指针,如果有环,最终快慢指针会在非NULL相遇
注:用到fast->next前先要确保fast非NULL,要用fast->next->next前先要确保fast,fast->next非NULL
复杂度:时间O(n), 空间O(1)
相关题目:Linked List CycleII...
分类:
其他好文 时间:
2014-05-15 07:01:57
阅读次数:
219
链接:http://soj.me/1302
题目中有图和表格,所以就不把题目信息列出来了,打开链接直接看就行了。。。
分析:
从填幻方的过程,可以判断一下几点:
1>.幻方的每一列都是向下发展的;
2>.填入的前n个数都刚好是每一列第一个填入的数;
从这两点可以推出下面几点:
(1). 每一列的发展是平面的(即每一列的个数是一样的,特别的,只有一列少一);
(2). 右下角...
分类:
其他好文 时间:
2014-05-15 07:01:20
阅读次数:
217
1、获取javascript API 服务方法,首先申请密钥(ak),才可成功加载APIJS文件。
使用方法如下:
http://api.map.baidu.com/api?v=2.0&ak=您的密钥">>
如果需要限制区域,那么需要引入下面的js
http://api.map.baidu.com/library/AreaRestriction/1.2/src/AreaRestrict...
分类:
Web程序 时间:
2014-05-15 06:49:02
阅读次数:
470
【题目】
You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list.
Input: (2 -> 4 -> 3) + (5 -> 6 -> 4)
Out...
分类:
其他好文 时间:
2014-05-15 05:13:49
阅读次数:
306
三个界面来学习$_SESSION的使用
第一个界面:
对应的代码:
我的商品列表
三国演义
水浒传
红楼梦
鲁迅全集
西游记
查看购物车
第二个界面:
对应代码:
<?php
echo "购买商品成功";
...
分类:
其他好文 时间:
2014-05-15 05:08:43
阅读次数:
376
1 sourceinsight screen font 的默认字体是Verdana的,它是一直变宽字体。在Document style中可以将字体改为定宽的Courier
2 document
options->auto indent 去掉indent Open Brace和Indent Close Brace的效果: 继上一段,在相对缩进行里, 如果输入"{"或"}", 则自动和上一行...
分类:
其他好文 时间:
2014-05-15 04:33:36
阅读次数:
330
学校的一些检查貌似要和这边的外包项目冲突了,比较纠结,按这个情况下去这个项目2周肯定解决不了。>__
360那边2周后也有比赛,报了一下名,有时间就去。
freebuf非常仗义的给我发了一个ipad mini,给领导大大跪了,以后好好翻译文章。
准备上手一下kail,用windows用的我蛋疼了,而且看起来也没有linux专业。
希望这个月能平安度过,最好能入手一个不错的本子。
阿弥陀佛...
分类:
其他好文 时间:
2014-05-15 03:28:18
阅读次数:
239
/*
* hdu 最小公倍数
* date 2014/5/13
* state AC
*/
#include
using namespace std;
int gcd(int x,int y)
{
while(x!=y)
{
if(x>y)x=x-y;
else y=y-x;
}
return x;
}
int main()
...
分类:
其他好文 时间:
2014-05-14 14:29:59
阅读次数:
225