LeetCode 编程训练的积累,目前在努力做题中,日后整理!
<!– more –>
1 binary tree traversal
1.1 level order
1 | type TreeNode struct { |
1 | func main() { |
1.2 level order bottom
1 | <<bt-level-order>> |
1 | func main() { |
1.3 zigzag level order
1 | <<bt-level-order>> |
1 | func main() { |
1.4 inOrder
1 | type TreeNode struct { |
1 | func main() { |
1.5 preOrder
1 | type TreeNode struct { |
1 | func main() { |
1.6 postOrder
1 | type TreeNode struct { |
1 | func main() { |
2 binary tree
1 | type TreeNode struct { |
1 | struct TreeLinkNode { |
1 | struct TreeNode { |
2.1 max depth
1 | type TreeNode struct { |
1 | func main() { |
2.2 paths
1 | type TreeNode struct { |
1 | func main() { |
2.3 isBalanced
1 | <<bt-max-depth>> |
1 | func main() { |
2.4 invert
1 | type TreeNode struct { |
1 | func main() { |
2.5 tilt
1 | type TreeNode struct { |
1 | func main() { |
2.6 construct string
1 | func tree2str(t *TreeNode) string { |
2.7 symmetric
1 | type TreeNode struct { |
1 | func main() { |
2.8 subtree
1 | type TreeNode struct { |
1 | func main() { |
2.9 diameter
1 | type TreeNode struct { |
1 | func main() { |
2.10 count complete tree nodes
1 | struct TreeNode { |
1 | int main() { |
2.11 implement trie
1 | type Trie struct { |
1 | func main() { |
2.12 merge two binary tree
1 | func mergeTrees(t1 *TreeNode, t2 *TreeNode) *TreeNode { |
1 | func main() { |
2.13 flatten bt to linked list
1 | func flatten(root *TreeNode) { |
1 | func main() { |
2.14 sum of left leaves
1 | func sumOfLeftLeaves(root *TreeNode) int { |
1 | func main() { |
2.15 find bottom left tree value
1 | func findBottomLeftValue(root *TreeNode) int { |
1 | func main() { |
2.16 right side view
1 | func rightSideView(root *TreeNode) []int { |
1 | func main() { |
2.17 find largest value in each tree row
1 | func largestValues(root *TreeNode) []int { |
1 | func main() { |
2.18 most frequent subtree sum
1 | func findFrequentTreeSum(root *TreeNode) []int { |
1 | func main() { |
2.19 construct binary tree from preorder and inorder traversal
1 | func buildTree(preorder []int, inorder []int) *TreeNode { |
1 | func main() { |
2.20 construct binary tree from inorder and postorder traversal
1 | func buildTree(inorder []int, postorder []int) *TreeNode { |
1 | func main() { |
2.21 populating next right pointers in each node
1 | struct TreeLinkNode { |
1 | int main() { |
2.22 add one row to tree
1 | func addOneRow(root *TreeNode, v int, d int) *TreeNode { |
1 | func main() { |
2.23 lowest common ancestor of a bt
1 | class Solution { |
1 | int main() { |
2.24 serialize and deserialize bt
1 | <<bt-node-def-cpp>> |
1 | using namespace std; |
2.25 average of levels in binary tree
1 | func averageOfLevels(root *TreeNode) []float64 { |
1 | func main() { |
3 bst
3.1 BSTIterator
1 | struct TreeNode { |
1 | int main() { |
3.2 to greater tree
1 | type TreeNode struct { |
1 | func main() { |
3.3 validate
1 | type TreeNode struct { |
1 | func main() { |
3.4 find mode
1 | type TreeNode struct { |
1 | func main() { |
3.5 convert sorted array to bst
1 | func sortedArrayToBST(nums []int) *TreeNode { |
1 | func main() { |
3.6 lowest common ancestor
1 | struct TreeNode { |
1 | int main() { |
3.7 recover binary search tree
1 | type TreeNode struct { |
1 | func main() { |
3.8 delete node
1 | type TreeNode struct { |
1 | func main() { |
3.9 convert sorted list to bst
1 | type ListNode struct { |
1 | func main() { |
3.10 kth smallest elemen
1 | type KthNode struct { |
1 | func main() { |
3.11 unique bst
1 | func numTrees(n int) int { |
1 | func main() { |
3.12 unique bst II
1 | func generateTrees(n int) []*TreeNode { |
1 | func main() { |
Render by hexo-renderer-org with Emacs 25.3.2 (Org mode 8.2.10)