JasonChang

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 18 下一页

2013年11月12日

摘要: 1 public class Solution { 2 public ArrayList inorderTraversal(TreeNode root) { 3 // IMPORTANT: Please reset any member data you declared, as 4 // the same Solution instance will be reused for each test case. 5 ArrayList result = new ArrayList(); 6 traversal(root,... 阅读全文
posted @ 2013-11-12 12:00 JasonChang 阅读(127) 评论(0) 推荐(0) 编辑

摘要: 1 public class Solution { 2 public ArrayList generateTrees(int n) { 3 // IMPORTANT: Please reset any member data you declared, as 4 // the same Solution instance will be reused for each test case. 5 return generate(1, n); 6 } 7 public ArrayList generate(int start... 阅读全文
posted @ 2013-11-12 11:49 JasonChang 阅读(157) 评论(0) 推荐(0) 编辑

摘要: 1 public class Solution { 2 public boolean isValidBST(TreeNode root) { 3 // IMPORTANT: Please reset any member data you declared, as 4 // the same Solution instance will be reused for each test case. 5 if(root == null) 6 return true; 7 if(root.left !=... 阅读全文
posted @ 2013-11-12 06:54 JasonChang 阅读(174) 评论(0) 推荐(0) 编辑

摘要: BFS 1 public class Solution { 2 public ArrayList> zigzagLevelOrder(TreeNode root) { 3 // IMPORTANT: Please reset any member data you declared, as 4 // the same Solution instance will be reused for each test case. 5 LinkedList visiting = new LinkedList(); 6 LinkedL... 阅读全文
posted @ 2013-11-12 06:13 JasonChang 阅读(164) 评论(0) 推荐(0) 编辑

2013年11月11日

摘要: 1 public class Solution { 2 public TreeNode buildTree(int[] inorder, int[] postorder) { 3 // IMPORTANT: Please reset any member data you declared, as 4 // the same Solution instance will be reused for each test case. 5 if(inorder == null||postorder == null||inorder.lengt... 阅读全文
posted @ 2013-11-11 17:10 JasonChang 阅读(185) 评论(0) 推荐(0) 编辑

摘要: 1 public class Solution { 2 public ArrayList> levelOrderBottom(TreeNode root) { 3 // IMPORTANT: Please reset any member data you declared, as 4 // the same Solution instance will be reused for each test case. 5 ArrayList> result = new ArrayList>(); 6 if(root == n... 阅读全文
posted @ 2013-11-11 16:31 JasonChang 阅读(183) 评论(0) 推荐(0) 编辑

摘要: 1 /** 2 * Definition for binary tree 3 * public class TreeNode { 4 * int val; 5 * TreeNode left; 6 * TreeNode right; 7 * TreeNode(int x) { val = x; } 8 * } 9 */10 public class Solution {11 public TreeNode sortedArrayToBST(int[] num) {12 // IMPORTANT: Please reset... 阅读全文
posted @ 2013-11-11 16:12 JasonChang 阅读(172) 评论(0) 推荐(0) 编辑

摘要: 1 /** 2 * Definition for binary tree 3 * public class TreeNode { 4 * int val; 5 * TreeNode left; 6 * TreeNode right; 7 * TreeNode(int x) { val = x; } 8 * } 9 */10 public class Solution {11 public boolean isBalanced(TreeNode root) {12 // IMPORTANT: Please reset an... 阅读全文
posted @ 2013-11-11 16:07 JasonChang 阅读(179) 评论(0) 推荐(0) 编辑

摘要: 1 public class Solution { 2 public ArrayList> pathSum(TreeNode root, int sum) { 3 // IMPORTANT: Please reset any member data you declared, as 4 // the same Solution instance will be reused for each test case. 5 ArrayList list = new ArrayList(); 6 ArrayList> resul... 阅读全文
posted @ 2013-11-11 16:00 JasonChang 阅读(171) 评论(0) 推荐(0) 编辑

摘要: 1 public class Solution { 2 public boolean hasPathSum(TreeNode root, int sum) { 3 // IMPORTANT: Please reset any member data you declared, as 4 // the same Solution instance will be reused for each test case. 5 if(root == null) 6 return false; 7 boole... 阅读全文
posted @ 2013-11-11 15:50 JasonChang 阅读(168) 评论(0) 推荐(0) 编辑

上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 18 下一页