摘要: 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, 阅读全文
posted @ 2018-12-31 19:23 fatttcat 阅读(106) 评论(0) 推荐(0) 编辑
摘要: 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 阅读全文
posted @ 2018-12-31 15:44 fatttcat 阅读(117) 评论(0) 推荐(0) 编辑
摘要: 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 阅读全文
posted @ 2018-12-31 15:01 fatttcat 阅读(90) 评论(0) 推荐(0) 编辑
摘要: 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 阅读全文
posted @ 2018-12-31 12:06 fatttcat 阅读(106) 评论(0) 推荐(0) 编辑
摘要: 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 阅读全文
posted @ 2018-12-31 11:39 fatttcat 阅读(101) 评论(0) 推荐(0) 编辑
摘要: 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 阅读全文
posted @ 2018-12-31 09:37 fatttcat 阅读(138) 评论(0) 推荐(0) 编辑
摘要: 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: 阅读全文
posted @ 2018-12-31 08:08 fatttcat 阅读(143) 评论(0) 推荐(0) 编辑
摘要: 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 阅读全文
posted @ 2018-12-31 08:01 fatttcat 阅读(115) 评论(0) 推荐(0) 编辑
摘要: 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 阅读全文
posted @ 2018-12-31 07:51 fatttcat 阅读(124) 评论(0) 推荐(0) 编辑
摘要: 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 阅读全文
posted @ 2018-12-31 07:31 fatttcat 阅读(141) 评论(0) 推荐(0) 编辑
摘要: 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 阅读全文
posted @ 2018-12-31 06:51 fatttcat 阅读(127) 评论(0) 推荐(0) 编辑