The gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integer n representing the total number of bits in the code, print the sequence of gray...
分类:
其他好文 时间:
2015-07-07 16:53:37
阅读次数:
108
Given a binary tree, return thelevel ordertraversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree{3,9,2...
分类:
其他好文 时间:
2015-07-07 16:30:04
阅读次数:
127
1. 问题描述 给定一个二叉搜索树,找出第k小的元素。注意:可以假设k总是存在,1≤k≤BST总元素数1 \le k \le BST总元素数。2. 方法与思路 根据二叉搜索树的特点,中序遍历的结果即是排序好的数组。那么找出第k小的数,只需要先进行一次中序遍历即可。
/**
* Definition for a binary tree node.
* struct TreeNode {...
分类:
其他好文 时间:
2015-07-07 13:09:15
阅读次数:
119
ueventd主要是负责设备节点的创建、权限设定等一些列工作。服务通过使用uevent,监控驱动发送的消息,做进一步处理。
ueventd实际和init是同一个binary,只是走了不同分支,可参看前一部分。
ueventd的整体代码比较简单,主要是三部分:
解析ueventd.rc 初始化设备信息 循环polling uevent消息
主函数及相关功能如下如下:
int ue...
分类:
移动开发 时间:
2015-07-07 13:04:59
阅读次数:
195
递归算法 1 /** 2 * Definition for a binary tree node. 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * TreeNode *right; 7 * ...
分类:
其他好文 时间:
2015-07-07 12:54:12
阅读次数:
107
定义
二叉树(binary tree)是n(n>=0)个结点的有限集合,该集合为空集合称为空二叉树,或者有一个根结点和两棵互不相交的,分别称为树根结点的左孩子树和右孩子树组成.
二叉树的特点
每个结点最多有两棵子树,所以二叉树总没有度大于2的结点
左子树和右子树是有顺序的,次数不能任意颠倒
即使树中某结点只有一棵子树,也要区分是左子树还是右子树
特殊的二叉树1. 斜树...
分类:
其他好文 时间:
2015-07-07 09:40:05
阅读次数:
170
题解:
Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).
For example:
Given binary tree {3,9,20,#,#,15,7},
3
/ 9...
分类:
编程语言 时间:
2015-07-07 09:39:22
阅读次数:
109
题目:
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,#,...
分类:
其他好文 时间:
2015-07-07 09:38:19
阅读次数:
127
题目:
Given a binary tree, determine if it is height-balanced.
For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node ne...
分类:
编程语言 时间:
2015-07-07 09:32:35
阅读次数:
154
就是递归class Solution: # @param {TreeNode} root # @return {TreeNode} def invertTree(self, root): if not root: return ro...
分类:
其他好文 时间:
2015-07-07 07:03:58
阅读次数:
100