摘要: 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 @ 2019-12-07 23:53 xuan_abc 阅读(96) 评论(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 @ 2019-12-07 23:27 xuan_abc 阅读(97) 评论(0) 推荐(0)
摘要: Given a binary tree, return all root-to-leaf paths. Note: A leaf is a node with no children. Example: Input: 1 / \ 2 3 \ 5 Output: ["1->2->5", "1->3"] 阅读全文
posted @ 2019-12-07 12:12 xuan_abc 阅读(119) 评论(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 @ 2019-12-07 11:21 xuan_abc 阅读(237) 评论(0) 推荐(0)
摘要: Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest l 阅读全文
posted @ 2019-12-07 10:36 xuan_abc 阅读(77) 评论(0) 推荐(0)
摘要: Given a binary search tree, write a function kthSmallest to find the kth smallest element in it. Note:You may assume k is always valid, 1 ≤ k ≤ BST's 阅读全文
posted @ 2019-12-07 10:06 xuan_abc 阅读(114) 评论(0) 推荐(0)