Given an array where elements are sorted in ascending order, convert it to a height balanced BST. 思路:使用二分法,将list的中间节点作为根节点,然后分别处理list左半边及右半边,以此递归. struct TreeNode { int val; TreeNode *left; TreeNode *right; TreeNode(int x) : val(x), left(NULL), right…
Construct Binary Tree from Inorder and Postorder Traversal Given inorder and postorder traversal of a tree, construct the binary tree. Note:You may assume that duplicates do not exist in the tree. Hide Tags Tree Array Depth-first Search SOLUTION 1:…
Yet Another Source Code for LintCode Current Status : 232AC / 289ALL in Language C++, Up to date (2016-02-10) For more problems and solutions, you can see my LintCode repository. I'll keep updating for full summary and better solutions. See cnblogs t…