Tree
文章平均质量分 70
cgdong2014
这个作者很懒,什么都没留下…
展开
-
Validate Binary Search Tree
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 nodes with keys less than the node's key.The原创 2015-01-11 03:31:15 · 206 阅读 · 0 评论 -
Balanced Binary Tree
Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never differ原创 2014-09-29 08:34:40 · 250 阅读 · 0 评论 -
Contains Duplicate III
Given an array of integers, find out whether there are two distinct indices i and j in the array such that the difference between nums[i] and nums[j] is at most t and the difference between i and j原创 2015-08-07 11:21:13 · 217 阅读 · 0 评论 -
Implement Trie (Prefix Tree)
Implement a trie with insert, search, and startsWith methods. Note: You may assume that all inputs are consist of lowercase letters a-z. Show Tags Show Similar Problems原创 2015-08-03 11:10:05 · 317 阅读 · 0 评论 -
Binary Tree Right Side View
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 example: Given the following binary tree, 1原创 2015-08-02 10:46:20 · 156 阅读 · 0 评论 -
Count Complete Tree Nodes
Given a complete binary tree, count the number of nodes. Definition of a complete binary tree from Wikipedia: In a complete binary tree every level, except possibly the last, is completely filled, a原创 2015-08-10 10:58:21 · 267 阅读 · 0 评论 -
Flatten Binary Tree to Linked List
Given a binary tree, flatten it to a linked list in-place. For example, Given 1 / \ 2 5 / \ \ 3 4 6 The flattened tree should look like: 1原创 2014-09-28 11:34:21 · 220 阅读 · 0 评论 -
Binary Search Tree Iterator
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 next smallest number in the BST. Note: next()原创 2015-01-06 02:19:17 · 232 阅读 · 0 评论 -
Find Next Node in InOrder Traverse
在一个二叉树的 Inorder 遍历中, 找到该节点的 下一个节点原创 2014-10-14 12:13:29 · 387 阅读 · 0 评论 -
Convert Sorted List to Binary Search Tree
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. 思路: Using slow and fast pointer to find the mid原创 2014-09-29 09:09:13 · 263 阅读 · 0 评论 -
Binary Tree Maximum Path Sum
Given a binary tree, find the maximum path sum. The path may start and end at any node in the tree. For example: Given the below binary tree, 1 / \ 2 3 Return 6.原创 2014-09-24 11:21:28 · 199 阅读 · 0 评论 -
Populating Next Right Pointers in Each Node II
Follow up for problem "Populating Next Right Pointers in Each Node". What if the given tree could be any binary tree? Would your previous solution still work? Note: You may only use constant extr原创 2014-09-26 12:17:31 · 240 阅读 · 0 评论 -
Diameter of Binary Tree
Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of the longestpath between any two nodes in a tree. This path may or may no原创 2017-04-03 15:09:46 · 285 阅读 · 0 评论