上一页 1 2 3 4 5 6 7 8 9 10 ··· 14 下一页
摘要: 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 @ 2020-03-12 04:48 米开朗菠萝 阅读(82) 评论(0) 推荐(0)
摘要: Given n, how many structurally unique BST's (binary search trees) that store values 1 ... n? Example: Input: 3 Output: 5 Explanation: Given n = 3, the 阅读全文
posted @ 2020-03-11 11:01 米开朗菠萝 阅读(114) 评论(0) 推荐(0)
摘要: You need to find the largest value in each row of a binary tree. Example: Input: 1 / \ 3 2 / \ \ 5 3 9 Output: [1, 3, 9] # Definition for a binary tre 阅读全文
posted @ 2020-03-10 20:22 米开朗菠萝 阅读(134) 评论(0) 推荐(0)
摘要: Given a binary tree, find the leftmost value in the last row of the tree. Example 1: Input: 2 / \ 1 3 Output: 1 Example 2: Input: 1 / \ 2 3 / / \ 4 5 阅读全文
posted @ 2020-03-10 20:10 米开朗菠萝 阅读(119) 评论(0) 推荐(0)
摘要: Find the sum of all left leaves in a given binary tree. Example: 3 / \ 9 20 / \ 15 7 There are two left leaves in the binary tree, with values 9 and 1 阅读全文
posted @ 2020-03-10 19:41 米开朗菠萝 阅读(139) 评论(0) 推荐(0)
摘要: Given a binary tree, return the preorder traversal of its nodes' values. Example: Input: [1,null,2,3] 1 \ 2 / 3 Output: [1,2,3] Follow up: Recursive s 阅读全文
posted @ 2020-03-08 11:05 米开朗菠萝 阅读(91) 评论(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 @ 2020-03-08 10:53 米开朗菠萝 阅读(127) 评论(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 @ 2020-03-08 10:35 米开朗菠萝 阅读(125) 评论(0) 推荐(0)
摘要: Given a binary tree, flatten it to a linked list in-place. For example, given the following tree: 1 / \ 2 5 / \ \ 3 4 6 The flattened tree should look 阅读全文
posted @ 2020-03-07 16:07 米开朗菠萝 阅读(84) 评论(0) 推荐(0)
摘要: Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum. N 阅读全文
posted @ 2020-03-07 15:19 米开朗菠萝 阅读(144) 评论(0) 推荐(0)
上一页 1 2 3 4 5 6 7 8 9 10 ··· 14 下一页