随笔分类 -  Tree

摘要: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 阅读全文 »
posted @ 2018-12-17 22:39 Veritas_des_Liberty 阅读(457) 评论(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 阅读全文 »
posted @ 2018-12-12 18:12 Veritas_des_Liberty 阅读(177) 评论(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-10 18:00 Veritas_des_Liberty 阅读(205) 评论(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 阅读全文 »
posted @ 2018-12-10 17:15 Veritas_des_Liberty 阅读(195) 评论(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 阅读全文 »
posted @ 2018-12-09 21:13 Veritas_des_Liberty 阅读(202) 评论(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 阅读全文 »
posted @ 2018-12-09 18:53 Veritas_des_Liberty 阅读(182) 评论(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 阅读全文 »
posted @ 2018-12-09 18:14 Veritas_des_Liberty 阅读(215) 评论(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], 阅读全文 »
posted @ 2018-12-08 21:40 Veritas_des_Liberty 阅读(219) 评论(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 阅读全文 »
posted @ 2018-12-04 12:27 Veritas_des_Liberty 阅读(663) 评论(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 阅读全文 »
posted @ 2018-12-04 11:59 Veritas_des_Liberty 阅读(254) 评论(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 阅读全文 »
posted @ 2018-12-03 19:14 Veritas_des_Liberty 阅读(323) 评论(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 阅读全文 »
posted @ 2018-12-01 11:04 Veritas_des_Liberty 阅读(294) 评论(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 阅读全文 »
posted @ 2018-11-30 22:34 Veritas_des_Liberty 阅读(296) 评论(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 阅读全文 »
posted @ 2018-11-29 22:34 Veritas_des_Liberty 阅读(438) 评论(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 阅读全文 »
posted @ 2018-11-29 21:13 Veritas_des_Liberty 阅读(285) 评论(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 阅读全文 »
posted @ 2018-11-28 21:18 Veritas_des_Liberty 阅读(238) 评论(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 阅读全文 »
posted @ 2018-11-27 15:26 Veritas_des_Liberty 阅读(178) 评论(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 阅读全文 »
posted @ 2018-11-27 13:09 Veritas_des_Liberty 阅读(176) 评论(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 阅读全文 »
posted @ 2018-11-26 22:11 Veritas_des_Liberty 阅读(192) 评论(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 阅读全文 »
posted @ 2018-11-24 22:30 Veritas_des_Liberty 阅读(191) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示