题意:给定一棵二叉树,返回按层遍历的结果
思路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
Robot Motion
Problem Description
A robot has been programmed to follow the instructions in its path. Instructions for the next direction the robot is to move are laid down in a grid. The...
分类:
其他好文 时间:
2014-05-15 05:48:40
阅读次数:
346
Sudo是Unix/Linux平台上的一个非常有用的工具,它允许系统管理员分配给普通用户一些合理的“权力”,让他们执行一些只有超级用户或其他特许用户才能完成的任务(主要体现为命令),比如:运行一些像mount,halt,su,useradd、userdel之类的命令,或者编辑一些系统配置文件,像/etc/mtab, /etc/samba/smb.conf等。这样以来,就不仅减少了root用户的登陆...
分类:
系统相关 时间:
2014-05-15 04:08:09
阅读次数:
320
引言:
执行如下命令时,ls /usr/local/lib/libfreetype.so -l显示内容:
lrwxrwxrwx 1 root root 20 2014-04-06 22:57 /usr/local/lib/libfreetype.so -> libfreetype.so.6.9.0
表明这是一个链接文件,通过链接可以实现对一个文件从不同路径对它进行引用。对于文件的链接有硬链接...
分类:
系统相关 时间:
2014-05-15 03:39:10
阅读次数:
381
Windows中Shift+右键"在此处打开命令窗口"默认是采用cmd的方式打开.把cmd替换为PowerShell的方式打开.1.Ctrl+R输入regedit进入注册表2.找到[HKEY_CLASSES_ROOT\Directory\Background\shell\cmd\command]3.修改数据为powershell.exe-NoExitSet-Location"%V"
分类:
其他好文 时间:
2014-05-14 18:47:32
阅读次数:
398
用rvm安装ruby错误缺少对于的库文件[root@localhost~]#rvminstall2.0.0Searchingforbinaryrubies,thismighttakesometime.Nobinaryrubiesavailablefor:redhat/6/i386/ruby-2.0.0-p451.Continuingwithcompilation.Pleaseread‘rvmhelpmount‘togetmoreinformationonbinaryrubies.Ch..
分类:
其他好文 时间:
2014-05-14 16:42:26
阅读次数:
620
分类:1)通过mii-tool指令[root@localhostroot]#mii-tooleth0:negotiated100baseTx-FD,linkoketh1:nolink或[root@localhostroot]#mii-tool-veth0:negotiated100baseTx-FD,linkokproductinfo:vendor00:50:43,model2rev3basicmode:autonegotiationenabledbasicstatus:autonegotia..
分类:
系统相关 时间:
2014-05-14 16:38:17
阅读次数:
397
ERROR1045(28000):Accessdeniedforuser‘root‘@‘localhost‘(usingpassword:YES)解决:1、先停止mysql服务,命令如下:#/etc/init.d/mysqlstop2、重新启动服务,命令如下:#/etc/init.d/mysqlstop#mysqld_safe--user=mysql--skip-grant-tables--skip-networking&3、登入mysql..
分类:
数据库 时间:
2014-05-14 16:36:13
阅读次数:
368
对于很多新手,当然我也是新手,在命令行里学习python的时候占满了屏幕,很不习惯,特别是使用linux习惯了,使用clear清屏,这样的感觉非常好,但是python下面没有这样的命令和功能,下面为了解决这个问题,本人写了个简单的模块1先来看下没有清屏的结果[root@zh~]#python
Pyth..
分类:
编程语言 时间:
2014-05-14 16:04:24
阅读次数:
1320
linux执行free命令显示如下:[root@Linux~]#free
totalusedfreesharedbufferscached
Mem:805434418346246219720060528369948
-/+buffers/cache:14041486650196
Swap:524280144524136第1行total内存总数:8054344used已经使用的内存数:1834624free空闲的内存数:6219720shared当前..
分类:
系统相关 时间:
2014-05-14 15:56:09
阅读次数:
329