该题比较简单,递归交换每一个节点的左右子树即可。
class Solution {
public:
TreeNode* invertTree(TreeNode* root) {
if(root == NULL)
return NULL;
TreeNode* tmp = root -> left;
root -> le...
分类:
其他好文 时间:
2015-07-14 15:46:50
阅读次数:
89
堆真是一种简单而又神奇的数据结构,以前用它求过前kth的数,现在又可以用两个堆来动态求解中位数。算法: 构建一个大顶堆和一个小顶堆,分别记为g和l。 假设当前中位数为mid,新读入一个数为tmp,则: 1.如果tmp = mid,则将tmp插入小顶堆,跳到步骤4。 3.如果大顶堆的元素个数比...
分类:
其他好文 时间:
2015-07-14 15:00:42
阅读次数:
93
该题的思路很明确就是将中缀表达式转换为后缀表达式,然后通过后缀表达式来求值。
class Solution {
public:
int calculate(string s) {
vector postorder;
stack ccache;
stack icache;
string tmp;
...
分类:
其他好文 时间:
2015-07-14 13:35:57
阅读次数:
83
int main(){ int MaxSize = 100,i,j; char tmp[10]; PtrToStack s; s = CreateStack(MaxSize); while( scanf("%s",tmp) != EOF ) { in...
分类:
其他好文 时间:
2015-07-14 11:15:36
阅读次数:
129
一、awk基本用法awk[options]‘scripts‘file1,file2...awk[options]‘pattern{action}‘file1,file2...#-F选项指定分隔符,$num,代表第num个字段
[root@docker1~]#awk-F:‘{print$1,$3}‘/tmp/passwd
root0
bin1
daemon2
adm3
......
#匹配正则表达式用:/正则表达式/,匹配以r开头..
分类:
其他好文 时间:
2015-07-14 06:26:21
阅读次数:
120
今天遇到了这么一个问题,同事写的SQL文件中有212条SQL,全部SQL都使用select...intooutfile形式,但是在导出文件名都为"/opt/export/tmp.dat",所以在运行时第二条SQL就报错"/opt/export/tmp.dat"已经存在导致脚本运行失败。于是,就写一个小脚本来解决此问题。需求是这样的,..
分类:
系统相关 时间:
2015-07-14 06:23:28
阅读次数:
142
//将中缀表达式转换为后缀表达式intmain(){ int MaxSize = 10; int str[8]={3,3,2,1,0,1,0,2}; char tmp; PtrToStack s; s = CreateStack( MaxSize ); while...
分类:
其他好文 时间:
2015-07-13 20:02:11
阅读次数:
101
一、导出csv文件利用Oracle中的Spool缓冲池技术可以实现Oracle数据导出到文本文件。1)、在Oracle PL/SQL中输入缓冲开始命令,并指定输出的文件名:spool /tmp/songjd/export.txt2)、在命令行中随便输入你的SQL查询:select mobile fr...
分类:
数据库 时间:
2015-07-13 10:02:52
阅读次数:
206
1.2.3.使用tail -f /tmp/yu.log 动态查看计划日志文件 也可以只查看3条 tail -3 /tmp/yu.log4.
分类:
其他好文 时间:
2015-07-12 23:06:22
阅读次数:
138
MySQL的配置文件/etc/my.cnf编辑配置文件[root@LAMPLINUX~]#vim/etc/my.cnf#TheMySQLserver[mysqld]port=3306socket=/tmp/mysql.sockskip-lockingkey_buffer_size=256Mmax_allowed_packet=1Mtable_open_cache=256sort_buffer_size=1Mread_buffer_size=1Mread_rnd_buffer_size=4..
分类:
数据库 时间:
2015-07-12 08:26:44
阅读次数:
163