摘要:
Given preorder and inorder traversal of a tree, construct the binary tree. Note:You may assume that duplicates do not exist in the tree. For example, 阅读全文
摘要:
Serialization is the process of converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or 阅读全文
摘要:
Given a binary tree, flatten it to a linked list in-place. For example, given the following tree: The flattened tree should look like: 每个节点的右节点都是preor 阅读全文
摘要:
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. Example 阅读全文
摘要:
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 阅读全文
摘要:
Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as follows: The left subtree of a node contains only 阅读全文
摘要:
A binary tree is univalued if every node in the tree has the same value. Return true if and only if the given tree is univalued. Example 1: Example 2: 阅读全文
摘要:
Given an n-ary tree, return the preorder traversal of its nodes' values. For example, given a 3-ary tree: Return its preorder traversal as: [1,3,5,6,2 阅读全文
摘要:
Given an n-ary tree, return the postorder traversal of its nodes' values. For example, given a 3-ary tree: Return its postorder traversal as: [5,6,3,2 阅读全文
摘要:
Given a non-empty binary tree, return the average value of the nodes on each level in the form of an array. Example 1: Note: M1: BFS 注意!sum要用long,用int 阅读全文
摘要:
Given a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus sum of all 阅读全文