上一页 1 ··· 20 21 22 23 24 25 26 27 28 ··· 32 下一页
摘要: Given a binary search tree with non-negative values, find the minimum absolute difference between values of any two nodes. Solution 1://先遍历左节点然后把左节点设为 阅读全文
posted @ 2019-03-15 15:16 MarkLeeBYR 阅读(146) 评论(0) 推荐(0)
摘要: Given a binary tree, find the length of the longest path where each node in the path has the same value. This path may or may not pass through the roo 阅读全文
posted @ 2019-03-15 15:13 MarkLeeBYR 阅读(159) 评论(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 @ 2019-03-15 15:11 MarkLeeBYR 阅读(159) 评论(0) 推荐(0)
摘要: //Solution 1:递归 public List<Integer> inorderTraversal(TreeNode root) { List<Integer> list =new ArrayList<>(); addNode(list, root); return list;}privat 阅读全文
posted @ 2019-03-15 15:02 MarkLeeBYR 阅读(75) 评论(0) 推荐(0)
摘要: Given n, how many structurally unique BST's (binary search trees) that store values 1...n? For example,Given n = 3, there are a total of 5 unique BST' 阅读全文
posted @ 2019-03-15 14:59 MarkLeeBYR 阅读(91) 评论(0) 推荐(0)
摘要: Given an integer n, generate all structurally unique BST's (binary search trees) that store values 1...n. For example,Given n = 3, your program should 阅读全文
posted @ 2019-03-15 14:49 MarkLeeBYR 阅读(92) 评论(0) 推荐(0)
摘要: Solution 1: public List<List<Integer>> levelOrder(TreeNode root) { Queue<TreeNode> queue = new LinkedList<>(); List<List<Integer>> wrapList = new Link 阅读全文
posted @ 2019-03-15 14:43 MarkLeeBYR 阅读(89) 评论(0) 推荐(0)
摘要: Solution 1: public class Solution { public List<List<Integer>> zigzagLevelOrder(TreeNode root) { List<List<Integer>> sol = new ArrayList<>(); travel(r 阅读全文
posted @ 2019-03-15 14:35 MarkLeeBYR 阅读(90) 评论(0) 推荐(0)
摘要: Given preorder and inorder traversal of a tree, construct the binary tree. Note:You may assume that duplicates do not exist in the tree. 见剑指offer重建二叉树 阅读全文
posted @ 2019-03-15 14:26 MarkLeeBYR 阅读(100) 评论(0) 推荐(0)
摘要: Given inorder and postorder traversal of a tree, construct the binary tree. Note:You may assume that duplicates do not exist in the tree. class Soluti 阅读全文
posted @ 2019-03-15 14:20 MarkLeeBYR 阅读(72) 评论(0) 推荐(0)
上一页 1 ··· 20 21 22 23 24 25 26 27 28 ··· 32 下一页