随笔分类 - Tree
发表于 2018-12-17 22:39阅读:457评论:0推荐:0
摘要:Median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value. So the median is the mean of the two
阅读全文 »
发表于 2018-12-12 18:12阅读:177评论:0推荐:0
摘要:Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. For this problem, a height-balanced bina
阅读全文 »
发表于 2018-12-10 18:00阅读:205评论: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
阅读全文 »
发表于 2018-12-10 17:15阅读:195评论:0推荐:0
摘要:Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number. An example is the root-to-leaf path 1->2->3 whic
阅读全文 »
发表于 2018-12-09 21:13阅读:202评论:0推荐:0
摘要:Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum. Note: A leaf is a node with no children. Exampl
阅读全文 »
发表于 2018-12-09 18:53阅读:182评论:0推荐:0
摘要:Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest l
阅读全文 »
发表于 2018-12-09 18:14阅读:215评论:0推荐:0
摘要:Two elements of a binary search tree (BST) are swapped by mistake. Recover the tree without changing its structure. Example 1: Input: [1,3,null,null,2
阅读全文 »
发表于 2018-12-08 21:40阅读:219评论:0推荐:0
摘要:Given an integer n, generate all structurally unique BST's (binary search trees) that store values 1 ... n. Example: Input: 3 Output: [ [1,null,3,2],
阅读全文 »
发表于 2018-12-04 12:27阅读:663评论:0推荐:0
摘要:Given the root node of a binary search tree, return the sum of values of all nodes with value between L and R (inclusive). The binary search tree is g
阅读全文 »
发表于 2018-12-04 11:59阅读:254评论:0推荐:0
摘要: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. Exa
阅读全文 »
发表于 2018-12-03 19:14阅读:323评论:0推荐:0
摘要:Implement a MyCalendarThree class to store your events. A new event can always be added. Your class will have one method, book(int start, int end). Fo
阅读全文 »
发表于 2018-12-01 11:04阅读:294评论:0推荐:0
摘要:Given a binary search tree with non-negative values, find the minimum absolute difference between values of any two nodes. Example: Input: 1 \ 3 / 2 O
阅读全文 »
发表于 2018-11-30 22:34阅读:296评论:0推荐:0
摘要:Given an array nums, we call (i, j) an important reverse pair if i < j and nums[i] > 2*nums[j]. You need to return the number of important reverse pai
阅读全文 »
发表于 2018-11-29 22:34阅读:438评论:0推荐:0
摘要:Given a data stream input of non-negative integers a1, a2, ..., an, ..., summarize the numbers seen so far as a list of disjoint intervals. For exampl
阅读全文 »
发表于 2018-11-29 21:13阅读:285评论:0推荐:0
摘要:Given an integer array nums, return the number of range sums that lie in [lower, upper] inclusive.Range sum S(i, j) is defined as the sum of the eleme
阅读全文 »
发表于 2018-11-28 21:18阅读:238评论:0推荐:0
摘要:You are given an integer array nums and you have to return a new counts array. The counts array has the property where counts[i] is the number of smal
阅读全文 »
发表于 2018-11-27 15:26阅读:178评论:0推荐:0
摘要:Given an array where elements are sorted in ascending order, convert it to a height balanced BST. For this problem, a height-balanced binary tree is d
阅读全文 »
发表于 2018-11-27 13:09阅读:176评论:0推荐:0
摘要: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 dep
阅读全文 »
发表于 2018-11-26 22:11阅读:192评论:0推荐:0
摘要:Given an array of integers, find out whether there are two distinct indices i and j in the array such that the absolute difference between nums[i] and
阅读全文 »
发表于 2018-11-24 22:30阅读:191评论:0推荐:0
摘要:Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST. According to the definition of LCA on Wikipedia
阅读全文 »