C++/** * Definition of TreeNode: * class TreeNode { * public: * int val; * TreeNode *left, *right; * TreeNode(int val) { * this->v...
分类:
其他好文 时间:
2015-11-27 12:53:28
阅读次数:
108
C++,递归 1 /** 2 * Definition of TreeNode: 3 * class TreeNode { 4 * public: 5 * int val; 6 * TreeNode *left, *right; 7 * TreeNode(int ...
分类:
其他好文 时间:
2015-11-27 00:53:23
阅读次数:
248
题目:Given a binary search tree, write a functionkthSmallestto find thekth smallest element in it.Note:You may assume k is always valid, 1 ≤ k ≤ BST's t...
分类:
其他好文 时间:
2015-11-27 00:42:42
阅读次数:
171
C++,递归 1 /** 2 * Definition of TreeNode: 3 * class TreeNode { 4 * public: 5 * int val; 6 * TreeNode *left, *right; 7 * TreeNode(int ...
分类:
其他好文 时间:
2015-11-27 00:39:53
阅读次数:
271
Given a binary tree, return thepreordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[1,2,3].Not...
分类:
其他好文 时间:
2015-11-26 22:43:47
阅读次数:
181
二叉排序树(Binary Sort Tree)又称二叉查找树(Binary Search Tree)。AVL树:在计算机科学中,AVL树是最先发明的自平衡二叉查找树。在AVL树中任何节点的两个子树的高度最大差别为一,所以它也被称为高度平衡树。AVL树在节点增删后不再满足AVL树条件,则需要“旋转”以...
分类:
其他好文 时间:
2015-11-26 15:06:59
阅读次数:
155
问题描述Given two binary strings, return their sum (also a binary string).For example,a ="11"b ="1"Return"100".算法代码一 1 public String addBinary(String a, S...
分类:
其他好文 时间:
2015-11-25 16:42:43
阅读次数:
141
题目:Invert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9to 4 / \ 7 2 / \ / \9 6 3 1Trivia:This problem was inspired byt...
分类:
其他好文 时间:
2015-11-25 13:14:34
阅读次数:
118
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 e...
分类:
其他好文 时间:
2015-11-25 11:33:08
阅读次数:
129
题目:Given acompletebinary tree, count the number of nodes.Definition of a complete binary tree fromWikipedia:In a complete binary tree every level, exc...
分类:
其他好文 时间:
2015-11-25 01:56:34
阅读次数:
157