随笔分类 -  bst

270. Closest Binary Search Tree Value
摘要:Given a non-empty binary search tree and a target value, find the value in the BST that is closest to the target. Note: Given target value is a floati 阅读全文

posted @ 2018-08-09 18:25 猪猪🐷

230. Kth Smallest Element in a BST
摘要:Find the kth smallest element in the tree: Log n to reach the smallest element Log n + k (amortized) Given a binary search tree, write a function kthS 阅读全文

posted @ 2018-08-09 18:23 猪猪🐷

235. Lowest Common Ancestor of a Binary Search Tree
摘要:带返回值的 recursion Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST. According to the definition of 阅读全文

posted @ 2018-08-09 17:34 猪猪🐷

173. 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 n 阅读全文

posted @ 2018-08-09 17:11 猪猪🐷

98. Validate Binary Search Tree
摘要:带返回值的 recursion. time: O(N), N is the number of nodes in the bst, space is O(1) , no extra space is used Given a binary tree, determine if it is a val 阅读全文

posted @ 2018-08-09 17:09 猪猪🐷

导航