本题也属于层次遍历的变形,不同之处在于其遍历的方法是交替进行的,形成一个ZigZag的曲线形式,如下:代码如下: 1 struct TreeNode { 2 int val; 3 TreeNode* left; 4 TreeNode* rig...
分类:
其他好文 时间:
2014-11-27 18:09:13
阅读次数:
132
题目:Binay Tree Level Order TraversalGiven a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level...
分类:
其他好文 时间:
2014-11-27 17:56:43
阅读次数:
110
数据库的随机查询SQL1. Oracle,随机查询20条select * from(select* from 表名order by dbms_random.value)where rownum <= 20;2.MS SQL Server,随机查询20条select top 20* from表名ord...
分类:
数据库 时间:
2014-11-27 17:48:27
阅读次数:
156
Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root).
For example:
Given binary tree {3,9,20,#,#,15,7},
...
分类:
其他好文 时间:
2014-11-27 16:14:23
阅读次数:
184
select * from (select * from order by desc) where rownum=1;select * from (select * from order by ) where rownum=1;
分类:
数据库 时间:
2014-11-27 15:50:00
阅读次数:
166
Given a sorted array of integers, find the starting and ending position of a given target value.
Your algorithm's runtime complexity must be in the order of O(log n).
If the target is not found ...
分类:
其他好文 时间:
2014-11-27 14:34:49
阅读次数:
200
The set[1,2,3,…,n]contains a total ofn! unique permutations.By listing and labeling all of the permutations in order,We get the following sequence (ie...
分类:
其他好文 时间:
2014-11-27 14:16:46
阅读次数:
156
处理百万级以上的数据提高查询速度的方法:1.应尽量避免在 where 子句中使用!=或操作符,否则将引擎放弃使用索引而进行全表扫描。2.对查询进行优化,应尽量避免全表扫描,首先应考虑在 where 及 order by 涉及的列上建立索引。3.应尽量避免在 where 子句中对字段进行 null 值...
分类:
其他好文 时间:
2014-11-27 12:25:14
阅读次数:
232
Basic Tree TraversalDepth First Traversal:1. In order traversal----left, root, right----4,2,5,1,32. Pre order traversal-----root, left, right-----1,2,...
分类:
其他好文 时间:
2014-11-27 07:59:38
阅读次数:
232
Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, ...
分类:
其他好文 时间:
2014-11-27 06:44:23
阅读次数:
118