随笔分类 -  Binary Tree

摘要:前序遍历的非递归实现 1 void PreOrder2(BTNode *root) { 2 BTNode *p = root; 3 stack<BTNode *> S; 4 while (p != NULL || !S.empty()) { 5 if (p) { 6 cout << p->val < 阅读全文 »
posted @ 2020-07-11 18:13 Veritas_des_Liberty 阅读(240) 评论(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) 编辑
摘要: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) 编辑
摘要:Design a class to find the kth largest element in a stream. Note that it is the kth largest element in the sorted order, not the kth distinct element. 阅读全文 »
posted @ 2018-11-24 22:11 Veritas_des_Liberty 阅读(294) 评论(0) 推荐(0) 编辑
摘要:Given a root node reference of a BST and a key, delete the node with the given key in the BST. Return the root node reference (possibly updated) of th 阅读全文 »
posted @ 2018-11-24 18:31 Veritas_des_Liberty 阅读(181) 评论(0) 推荐(0) 编辑
摘要:Given the root node of a binary search tree (BST) and a value to be inserted into the tree, insert the value into the BST. Return the root node of the 阅读全文 »
posted @ 2018-11-24 12:22 Veritas_des_Liberty 阅读(217) 评论(0) 推荐(0) 编辑
摘要:Given the root node of a binary search tree (BST) and a value. You need to find the node in the BST that the node's value equals the given value. Retu 阅读全文 »
posted @ 2018-11-24 11:40 Veritas_des_Liberty 阅读(193) 评论(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-11-24 10:51 Veritas_des_Liberty 阅读(228) 评论(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-11-24 09:58 Veritas_des_Liberty 阅读(220) 评论(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-11-23 20:45 Veritas_des_Liberty 阅读(306) 评论(0) 推荐(0) 编辑
摘要:Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. According to the definition of LCA on Wikipedia: “The lowes 阅读全文 »
posted @ 2018-11-23 15:50 Veritas_des_Liberty 阅读(173) 评论(0) 推荐(0) 编辑

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