摘要:
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
阅读(162)
评论(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
阅读(162)
评论(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
阅读(77)
评论(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
阅读(96)
评论(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
阅读(95)
评论(0)
推荐(0)
摘要:
Solution 1: public List<List<Integer>> levelOrder(TreeNode root) { Queue<TreeNode> q = new LinkedList<>(); List<List<Integer>> wrapList = new LinkedLi 阅读全文
posted @ 2019-03-15 14:43
MarkLeeBYR
阅读(91)
评论(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
阅读(95)
评论(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
阅读(103)
评论(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
阅读(78)
评论(0)
推荐(0)
摘要:
given a binary tree, return the preorder traversal of its nodes' values. Solution 1://非递归 Solution 1://非递归 public class Solution { public List<Integer 阅读全文
posted @ 2019-03-15 14:07
MarkLeeBYR
阅读(78)
评论(0)
推荐(0)
浙公网安备 33010602011771号