leetcode Tree 整理版

本次题解为 leetcode tree 的整理,包括

  • 依照leetcode定义 自己写的createTree方法,便于测试
  • 94 Binary Tree Inorder Traversal
  • 95 Unique Binary Search Trees II
  • 96 Unique Binary Search Trees
  • 98 Validate Binary Search Tree
  • 99 Recover Binary Search Tree
  • 100 Same Tree
  • 101 Symmetric Tree
  • 102 Binary Tree Level Order Traversal
  • 103 Binary Tree Zigzag Level Order Traversal
  • 104 Maximum Depth of Binary Tree
  • 105 Construct Binary Tree from Preorder and Inorder Traversal
  • 106 Construct Binary Tree from Inorder and Postorder Traversal
  • 107 Binary Tree Level Order Traversal II
  • 108 Convert Sorted Array to Binary Search Tree
  • 109 Convert Sorted List to Binary Search Tree
  • 110 Balanced Binary Tree
  • 111 Minimum Depth of Binary Tree
  • 112 Path Sum
  • 113 Path Sum II
  • 114 Flatten Binary Tree to Linked List
  • 116 Populating Next Right Pointers in Each Node
  • 117 Populating Next Right Pointers in Each Node II
  • 124 Binary Tree Maximum Path Sum
  • 129 Sum Root to Leaf Numbers
  • 144 Binary Tree Preorder Traversal
  • 145 Binary Tree Postorder Traversal
  • 173 Binary Search Tree Iterator
  • 199 Binary Tree Right Side View
  • 222 Count Complete Tree Nodes
  • 226 Invert Binary Tree
  • 230 Kth Smallest Element in a BST
  • 235 Lowest Common Ancestor of a Binary Search Tree
  • 236 Lowest Common Ancestor of a Binary Tree
  • 257 Binary Tree Paths
  • 297 Serialize and Deserialize Binary Tree
  • 449. Serialize and Deserialize BST

update : 2016-1-11

  • 新增两题LCA题解:
    • 235 Lowest Common Ancestor of a Binary Search Tree
    • 236 Lowest Common Ancestor of a Binary Tree

Continue reading