摘要:
Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom. For exa 阅读全文
摘要:
Given a binary tree, flatten it to a linked list in-place. For example,Given The flattened tree should look like: 思路: 将一个二叉树 就地 压成"链表"的结构; 阅读全文
摘要:
Given an array where elements are sorted in ascending order, convert it to a height balanced BST. 升序数组a[],构造平衡二叉树,左右子树高度差不超过1. 思路: 利用先序构建二叉树的方法,将数组的中间 阅读全文
摘要:
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 阅读全文
摘要:
Two elements of a binary search tree (BST) are swapped by mistake. Recover the tree without changing its structure. Note:A solution using O(n) space i 阅读全文
摘要:
Given an integer n, generate all structurally unique BST's (binary search trees) that store values 1...n. For example,Given n = 3, your program should 阅读全文
摘要:
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 lowes 阅读全文
摘要:
Given a binary tree, find the maximum path sum. For this problem, a path is defined as any sequence of nodes from some starting node to any node in th 阅读全文
摘要:
Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, 阅读全文