题目: Given a binary search tree, write a function kthSmallest to find the kth smallest element in it. Note: You may assume k is always valid, 1 ≤ k ≤ B
分类:
其他好文 时间:
2016-01-29 16:05:13
阅读次数:
141
Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST. According to the definition of LCA on Wikipedia
分类:
其他好文 时间:
2016-01-29 15:48:10
阅读次数:
128
题目: Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. According to the definition of LCA on Wikipedia: “The l
分类:
其他好文 时间:
2016-01-29 12:24:06
阅读次数:
125
题目: Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum. For example:Given the below binary tree and
分类:
其他好文 时间:
2016-01-29 11:56:46
阅读次数:
123
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 num
分类:
其他好文 时间:
2016-01-29 11:43:39
阅读次数:
133
Preorder class Solution { public: vector<int> preorderTraversal(TreeNode* root) { vector<int> res; if (!root) return res; stack<TreeNode *> sta; sta.p
分类:
其他好文 时间:
2016-01-29 11:31:25
阅读次数:
118
Given a binary tree, return the preorder traversal of its nodes' values. For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [1,2,3]. 思路:递归和迭代。
分类:
其他好文 时间:
2016-01-29 08:46:37
阅读次数:
117
Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and
分类:
其他好文 时间:
2016-01-29 08:43:45
阅读次数:
165
Using DFS to traverse the node and build the a tree. for a node, it has following properties: If its a left child node of its parent, then the left bo
分类:
其他好文 时间:
2016-01-29 08:42:46
阅读次数:
168
Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST. Calling next() will return the n
分类:
其他好文 时间:
2016-01-29 00:17:27
阅读次数:
197