2018年11月7日

331. Verify Preorder Serialization of a Binary Tree

摘要: One way to serialize a binary tree is to use pre-order traversal. When we encounter a non-null node, we record the node's value. If it is a null node, we record using a sentinel value such as #. ... 阅读全文

posted @ 2018-11-07 05:29 猪猪🐷 阅读(107) 评论(0) 推荐(0)

439. Ternary Expression Parser

摘要: Given a string representing arbitrarily nested ternary expressions, calculate the result of the expression. You can always assume that the given expression is valid and only consists of digits 0-9, ?... 阅读全文

posted @ 2018-11-07 05:28 猪猪🐷 阅读(92) 评论(0) 推荐(0)

536. Construct Binary Tree from String

摘要: You need to construct a binary tree from a string consisting of parenthesis and integers. The whole input represents a binary tree. It contains an integer followed by zero, one or two pairs of parent... 阅读全文

posted @ 2018-11-07 05:28 猪猪🐷 阅读(78) 评论(0) 推荐(0)

339. Nested List Weight Sum

摘要: Given a nested list of integers, return the sum of all integers in the list weighted by their depth. Each element is either an integer, or a list -- whose elements may also be integers or other lists... 阅读全文

posted @ 2018-11-07 05:27 猪猪🐷 阅读(107) 评论(0) 推荐(0)

364. Nested List Weight Sum II

摘要: Given a nested list of integers, return the sum of all integers in the list weighted by their depth. Each element is either an integer, or a list -- whose elements may also be integers or other lists... 阅读全文

posted @ 2018-11-07 05:26 猪猪🐷 阅读(79) 评论(0) 推荐(0)

671. Second Minimum Node In a Binary Tree

摘要: Given a non-empty special binary tree consisting of nodes with the non-negative value, where each node in this tree has exactly twoor zero sub-node. If the node has two sub-nodes, then this node's va... 阅读全文

posted @ 2018-11-07 05:19 猪猪🐷 阅读(86) 评论(0) 推荐(0)

107. Binary Tree Level Order Traversal II

摘要: Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root). For example:
Given binary tree [3,9,20,null,null,15,7... 阅读全文

posted @ 2018-11-07 05:16 猪猪🐷 阅读(70) 评论(0) 推荐(0)

515. Find Largest Value in Each Tree Row

摘要: You need to find the largest value in each row of a binary tree. Example: Input: 1 / \ 3 2 / \ \ 5 3 9 Output: [1, 3, 9] Bfs public int[] findV... 阅读全文

posted @ 2018-11-07 05:14 猪猪🐷 阅读(94) 评论(0) 推荐(0)

662. Maximum Width of Binary Tree

摘要: Given a binary tree, write a function to get the maximum width of the given tree. The width of a tree is the maximum width among all levels. The binary tree has the same structure as a full binary tr... 阅读全文

posted @ 2018-11-07 05:13 猪猪🐷 阅读(81) 评论(0) 推荐(0)

333. Largest BST Subtree

摘要: Given a binary tree, find the largest subtree which is a Binary Search Tree (BST), where largest means subtree with largest number of nodes in it. Note:
A subtree must include all of its descendants.... 阅读全文

posted @ 2018-11-07 05:11 猪猪🐷 阅读(91) 评论(0) 推荐(0)

652. Find Duplicate Subtrees

摘要: Given a binary tree, return all duplicate subtrees. For each kind of duplicate subtrees, you only need to return the root node of any one of them. Two trees are duplicate if they have the same struct... 阅读全文

posted @ 2018-11-07 05:10 猪猪🐷 阅读(88) 评论(0) 推荐(0)

572. Subtree of Another Tree

摘要: , 3, 4, 1, #, #, 2, 0, #, #, #, 5, #, # , 4, 1, #, #, 2, #, # , 3, 4, 1, #, #, 2, #, #, 5, #, # 阅读全文

posted @ 2018-11-07 05:10 猪猪🐷 阅读(97) 评论(0) 推荐(0)

742. Closest Leaf in a Binary Tree

摘要: Given a binary tree where every node has a unique value, and a target key k, find the value of the nearest leaf node to target k in the tree. Here, nearest to a leaf means the least number of edges t... 阅读全文

posted @ 2018-11-07 05:09 猪猪🐷 阅读(96) 评论(0) 推荐(0)

501. Find Mode in Binary Search Tree

摘要: Given a binary search tree (BST) with duplicates, find all the mode(s) (the most frequently occurred element) in the given BST. Assume a BST is defined as follows: * The left subtree of a node contai... 阅读全文

posted @ 2018-11-07 05:08 猪猪🐷 阅读(129) 评论(0) 推荐(0)

783. Minimum Distance Between BST Nodes

摘要: Given a Binary Search Tree (BST) with the root node root, return the minimum difference between the values of any two different nodes in the tree. Example : Input: root = [4,2,6,1,3,null,null] Output... 阅读全文

posted @ 2018-11-07 05:07 猪猪🐷 阅读(103) 评论(0) 推荐(0)

776. Split BST

摘要: Given a Binary Search Tree (BST) with root node root, and a target value V, split the tree into two subtrees where one subtree has nodes that are all smaller or equal to the target value, while the o... 阅读全文

posted @ 2018-11-07 05:06 猪猪🐷 阅读(133) 评论(0) 推荐(0)

538. Convert BST to Greater Tree

摘要: 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 keys greater than the original key in BST. Exampl... 阅读全文

posted @ 2018-11-07 05:06 猪猪🐷 阅读(76) 评论(0) 推荐(0)

255. Verify Preorder Sequence in Binary Search Tree

摘要: Given an array of numbers, verify whether it is the correct preorder traversal sequence of a binary search tree. You may assume each number in the sequence is unique. Consider the following binary se... 阅读全文

posted @ 2018-11-07 05:05 猪猪🐷 阅读(135) 评论(0) 推荐(0)

669. Trim a Binary Search Tree

摘要: Given a binary search tree and the lowest and highest boundaries as L and R, trim the tree so that all its elements lies in [L, R] (R >= L). You might need to change the root of the tree, so the resu... 阅读全文

posted @ 2018-11-07 05:05 猪猪🐷 阅读(116) 评论(0) 推荐(0)

215. Kth Largest Element in an Array

摘要: Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element. Example 1: Input: [3,2,1,5,6,4] and k = 2 Output: 5 Examp... 阅读全文

posted @ 2018-11-07 04:58 猪猪🐷 阅读(143) 评论(0) 推荐(0)

导航